Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp412299lqt; Mon, 18 Mar 2024 11:18:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3QooprWi1fCoP10DIvN9C9BAOzcgt/qzf61NPlKHT12KcHEE0otixqqtodvoPys/zH3duOFd/4Gh+7o3ZqI+wWDlI1KcaUyqJU0uDFg== X-Google-Smtp-Source: AGHT+IFvZfoWchGyVYZvEUl4RBt0keHg+tIwyCEzywhAq+2s16Zt4UczaFnTNNruLUUZ5U0dKRcK X-Received: by 2002:a05:651c:1023:b0:2d4:269e:59df with SMTP id w3-20020a05651c102300b002d4269e59dfmr185810ljm.52.1710785901480; Mon, 18 Mar 2024 11:18:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710785901; cv=pass; d=google.com; s=arc-20160816; b=lSyhH38l3E/jbkdRFR/M0Fhep80NTdrpVO0/b6QKkGdF4R2RukTo2Q7oaUDfAnwuYp 9GfM50G1Wmxzm4Bq2/WEtfWZZ4pWGLumFKfPP6PMwmN2V6u5jkQIPC/Yrsii6/DeMTFI r+VJpwYao3OO57Q7nIgO3ATkHb2HCRSIsw/SVOHt4/1MryL+JlTvck1bosPCsVTy1CGu 7WKPaA7kyCtUMmPjU6TpV/tm3oikCUIY1x5jh7X1tXVuCoOX1o59xkHOcHb/hJKpriTk obiHHFXdYfJyx4aRtsuNQNoxJHlGqYRcPxQXpK95+Iu1aCaaPsqblKz94nA6ms4C5Al2 6Q6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=grX7aOVEjcj1r427LkMK7/CrrCwMnrUUUMn3RrpkX/k=; fh=wArVu5OKVZMaGn4FP6E6GnmFn3I2/GahAiXSpV3u1VI=; b=kDCL0k/gPs82I1xA/PzcPOG2ni2Vgtrwfj21vLtTjF19bhQH58Wu9VwVwcR0O2+7bk MUa1w9GhdoWWs+6exEW06QVa3Bx82NKF1EMdqAfovB5G6IjsQ1Pgwh/DuoN2T/JehWNP calGZ8g8628wwUkFcmSbjB/mxqiSI3zyH4UNDUd75PXPyDzgzMjpI4lmH+crvzb9ZFST 1eALAFA8moJg22WYGZaLVtvRWGJ2FfwIf+J4Nj4+qqi3/KCXU3YIOjrtCVjNWHDVvSCx 93/HTryPwPjtTA9sM9gw1EcOPk14U2Yp+W+NcnRM1hUKsqiV7Jjp7wiGnbBuq4B7ea3h GQrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-106507-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106507-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g3-20020a0564021ec300b0056a2eba3d6esi1012722edg.23.2024.03.18.11.18.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 11:18:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106507-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-106507-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106507-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 366071F23D10 for ; Mon, 18 Mar 2024 18:18:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EA5956464; Mon, 18 Mar 2024 18:17:36 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65C9055E6B for ; Mon, 18 Mar 2024 18:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710785856; cv=none; b=XYNHNUMiH1XrUODZCzAmMBwZxJej85ZrzwN+XBx++zoROFeZubLAORLnxJVfyz1QlPhKGgubFU09rVxaZPEWNOQpq/iPvkoOOIpH9owDsyAgWlWLv3mQ2nz2sEkg/elEUsFNkvQI9Got1pEryosPOg0Pa69625EOkCU7aSEE9sc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710785856; c=relaxed/simple; bh=ljUrWkPTrnxySMMgHRBsRE9NywcmS1B0dCvLNhmjtR0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FSK5taXimkENeLF8ImeHhvcaZuq0JdkQWtLsHF3v/9kQSIEhpMt5sJ7DzlUte/oCFQ6k9/k74BQSlqPjPDfPo4/F2TAC9FYJJGVNbu58JTDAHvl70MJ71B77kcU9MREB2VRrGBXQzmTbm3TX2J+1/lEClUJqCKvHVa9fJnlv5FE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rmHY8-0000eM-7a; Mon, 18 Mar 2024 19:17:28 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rmHY7-0077xN-Pn; Mon, 18 Mar 2024 19:17:27 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rmHY7-00873f-2G; Mon, 18 Mar 2024 19:17:27 +0100 Date: Mon, 18 Mar 2024 19:17:27 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Nylon Chen Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, conor@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, thierry.reding@gmail.com, vincent.chen@sifive.com, zong.li@sifive.com, nylon7717@gmail.com Subject: Re: [PATCH v9 3/3] pwm: sifive: Fix the error in the idempotent test within the pwm_apply_state_debug function Message-ID: References: <20240222081231.213406-1-nylon.chen@sifive.com> <20240222081231.213406-4-nylon.chen@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="x44go5u7hgleqhj7" Content-Disposition: inline In-Reply-To: <20240222081231.213406-4-nylon.chen@sifive.com> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org --x44go5u7hgleqhj7 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, On Thu, Feb 22, 2024 at 04:12:31PM +0800, Nylon Chen wrote: > Round the result to the nearest whole number. This ensures that > real_period is always a reasonable integer that is not lower than the > actual value. >=20 > e.g. > $ echo 110 > /sys/devices/platform/led-controller-1/leds/d12/brightness > $ .apply is not idempotent (ena=3D1 pol=3D0 1739692/4032985) -> (ena=3D1 = pol=3D0 1739630/4032985) >=20 > Co-developed-by: Zong Li > Signed-off-by: Zong Li > Signed-off-by: Nylon Chen > --- > drivers/pwm/pwm-sifive.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c > index a586cfe4191b..bebcbebacccd 100644 > --- a/drivers/pwm/pwm-sifive.c > +++ b/drivers/pwm/pwm-sifive.c > @@ -101,7 +101,7 @@ static void pwm_sifive_update_clock(struct pwm_sifive= _ddata *ddata, > =20 > /* As scale <=3D 15 the shift operation cannot overflow. */ > num =3D (unsigned long long)NSEC_PER_SEC << (PWM_SIFIVE_CMPWIDTH + scal= e); > - ddata->real_period =3D div64_ul(num, rate); > + ddata->real_period =3D DIV_ROUND_UP_ULL(num, rate); > dev_dbg(ddata->chip.dev, > "New real_period =3D %u ns\n", ddata->real_period); > } pwm_sifive_apply has a DIV64_U64_ROUND_CLOSEST(). I wonder if that needs adaption, too?! Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --x44go5u7hgleqhj7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmX4hTYACgkQj4D7WH0S /k6K9QgAlQOk5zs1qZjx50SM5kcMxMw+J3ccF0gM0gezDCINIsFANkmsKs+qY3m9 b6NUelYUChHyY1+/zWpqLNGByQmGMm3yMBO4yZ3/jn/QPG1CxgejF6t60XVthOtr 9YjvOnCh9SSM5XkoPajFJ/n7qlk7T/xRA9+MBjSpwcVOicRZGE4FtFJ+AiToc5Yc uebQi/SfgQ9uTUmYgOZzUJo140Q3XnoGasCf+V9C3SUVOPCPunEmhBH8aq5H6wk7 D9fIOAVfxEK/YIHNIzv+KjrkJ6t/b5/yeYC3zQgMzvDZYW47aRhLNioG0hQcvdPO 2ED/sw3W2E6eBAm8IBCDIyN9LWdNRw== =tmD5 -----END PGP SIGNATURE----- --x44go5u7hgleqhj7--