Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp456593pxj; Tue, 18 May 2021 07:11:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTdCWX6DQg5IlNG9lBMTFiovRxok5ptvY8Ohl+v0GQrxQFPb41FtyuyBSr/4mN76F9JHGa X-Received: by 2002:a92:d983:: with SMTP id r3mr4098610iln.262.1621347062070; Tue, 18 May 2021 07:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621347062; cv=none; d=google.com; s=arc-20160816; b=SASusgVLOvbvQLrtN2odGVs+t7VbSUKhm26Zj4dpLSCWutP5S458F9y3SHOzLMjmFa LxpRmkeO/vemnlnVp65cgZN/5CUIJRs5LmytpdPCgBfvR1pZBTtyF1dG1YlAvFRv72Wl 24yodIaV3rSKZ0LQET+GX8px1cxpwzpgv/dk3GzQhysjKK0x6nd7eSRHEwf8Y0RERuZU Dy1dYn3rFT4YWzUqYLkjNfdy+Fyq/zpEfIXUGjgLXy4nGIoElWG+cmsEPZaF3wPMIjpr b8mnFyzL7pkd+KTmKQwhelxleoulo9+vYr5WFnHP/DIgXiyPkZzk5ZIxD1Pzr9/Cq1o6 u2NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8FgDoPY/KeKwH014z1USZcH0BG8eXIGJ6d1fbGgSYjI=; b=HnJtH98u5SbZ1Lq0HshYcmlL3pizs7klyIoVrZgkTbYJPdYq3kAxUNMdqKK1fsandc OC7c3P7eZg0sTBxCDI/2mpKu5WfO2ShaKAM3aW0I0A4xqE9jraeBBB90bZ+TJSpmBu1Z a800M4lMzv5+GGdWm/S7R4AjLhMVCZSUiPexaNAkpIJfGQZ2YjVmh35Owzka7QdzonKm 8VFRXX9rvVnIcRpuPrsE+6E87a1r/mSKqjZLlBsG5lwlYYVeuM5miMbibwH/B+NSOtvD dCTS4mubwbjTxD/dkAEmlHcEgEK96lKdWXkvEc+2+4lyolbNsUReH+vAb9pl9nvLK7w8 44tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d75ohmvw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y20si22784542ioj.68.2021.05.18.07.10.49; Tue, 18 May 2021 07:11:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d75ohmvw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343642AbhEQPmR (ORCPT + 99 others); Mon, 17 May 2021 11:42:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:52492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244363AbhEQP10 (ORCPT ); Mon, 17 May 2021 11:27:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 013CC61CA9; Mon, 17 May 2021 14:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262210; bh=9PKFT18dg3h1Ek+OQYRoxbOwHE+ndndJZOnlamMHxmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d75ohmvwrasTHirHb57JmsVDSTJ2gvAZHwnCi6FhrUnSjI2rEJhcnuC2JfIcjw1Y/ YYoLv9hVGeAG7m0rAh96HeTPJDSVeC5NaBl6aOZ2ih+vmVPAMoYKFw6T1HUo7BWJqX C9Cue7BL3uerlPaOL+iP9NEepHALpvOJWrLiuV2o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Thierry Reding , Sasha Levin Subject: [PATCH 5.10 134/289] pwm: atmel: Fix duty cycle calculation in .get_state() Date: Mon, 17 May 2021 16:00:59 +0200 Message-Id: <20210517140309.678277020@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Uwe Kleine-König [ Upstream commit 453e8b3d8e36ddcb283b3d1698864a03ea45599a ] The CDTY register contains the number of inactive cycles. .apply() does this correctly, however .get_state() got this wrong. Fixes: 651b510a74d4 ("pwm: atmel: Implement .get_state()") Signed-off-by: Uwe Kleine-König Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/pwm/pwm-atmel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 6161e7e3e9ac..d7cb0dfa25a5 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -319,7 +319,7 @@ static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, cdty = atmel_pwm_ch_readl(atmel_pwm, pwm->hwpwm, atmel_pwm->data->regs.duty); - tmp = (u64)cdty * NSEC_PER_SEC; + tmp = (u64)(cprd - cdty) * NSEC_PER_SEC; tmp <<= pres; state->duty_cycle = DIV64_U64_ROUND_UP(tmp, rate); -- 2.30.2