Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3081171pxj; Mon, 17 May 2021 17:17:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRQw9fJ+YJjIDkz5nuYIlSZt3/wH3OOYfxseh9YQLsgh0MfXuyT8MNNbQMyLi5k5Ryf0Qn X-Received: by 2002:aa7:dbcd:: with SMTP id v13mr3349900edt.59.1621297034822; Mon, 17 May 2021 17:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621297034; cv=none; d=google.com; s=arc-20160816; b=DQpLAto7j7hO8NN1DJcVJayHP8XDhJ//8Nd93tgL3H62vgxwYvg3QyCzesgW5kejSM 5scGaAaYsZSdLz8fg+Q1XY828FYuUPez1XrfmJr47zqiSOqc0pLcH34nGHjhAe8XML0e Fr5enNoxZbiTgLLepNlM1stQ8m4qa+lalJwdFYlKXfqdtxPijdqVoV3w2b3JbLOvWF8h Zeh5qgNUwsIUYlRanI40pKRw6mwlGErOU9PcyqTRxqfu9DgMJdlgMe1URTk3R5nK1RhC 5fback0hSVpjkorB/KHme1poP5XGGQ4m/CjlZGGo1YixhPr5oDIK9RfjQOMxC9LRNxog Yfkg== 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=gAzeEYI/+N7Jd/c4C315Kbh59ogJpxzfJpVMb49EdkY=; b=DMUlre6U/8jtYZ5t3A3cWjsgDvqq7fRmRmhYWXglrikwvfiZc95pp/s6/sZlcLSB9V DpM4wnRP6QS56uTFPdYqaPmQTiJLMj6ygE6Mvv4E898HMSwBleZ29U1NWgHHq7ftK4tH M9ZMPh0ikLTOOYQggEhkyCFMlmFkO3XCDm0qQQKh/X3I0jkF2J04s30EUDHIjA8urMxB tkGxdt0nNASxtunzaaCKKtOdEYjVLABOXr7CVpOKJEVF+6CL5AYkqWS+39bm8xPVwEaO RNNOPMlmJNvjwW6eI08WT0haonT0Crh0k0u4DhmseiELGwdj/SEHdQnW/dG0Ax/oAJu5 VASA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hd1NeBvl; 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 t23si15318589ejj.290.2021.05.17.17.16.51; Mon, 17 May 2021 17:17:14 -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=Hd1NeBvl; 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 S238027AbhEQO1f (ORCPT + 99 others); Mon, 17 May 2021 10:27:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:36118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237315AbhEQOWn (ORCPT ); Mon, 17 May 2021 10:22:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 366A361480; Mon, 17 May 2021 14:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260732; bh=y8jXhEd11/4EYV/k/XtYQHWWe8BXEbMqsd7gqkPtRyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hd1NeBvlJssdL9NmQGK8HXTDm1w8vL4eet7jk5qftj+6etjbkVemzqQZvv/VWO79j SdNhhlVLimGvPDtkP2iPOEFZUjm7btSxjYg6oZiBbT+Hngssiyk8cZmP2gNQMS/VCd z9lOCfRjByiI1WDEjtiftPdmsjEWFp0Wb+Q2piKY= 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.12 180/363] pwm: atmel: Fix duty cycle calculation in .get_state() Date: Mon, 17 May 2021 16:00:46 +0200 Message-Id: <20210517140308.681779469@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 5813339b597b..3292158157b6 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