[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230907213635.6ba43chppu556vda@pengutronix.de>
Date: Thu, 7 Sep 2023 23:36:35 +0200
From: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To: Ben Dooks <ben.dooks@...ethink.co.uk>
Cc: linux-pwm@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
Thierry Reding <thierry.reding@...il.com>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Greentime Hu <greentime.hu@...ive.com>,
jarkko.nikula@...ux.intel.com
Subject: Re: [PATCH v9 5/6] pwm: dwc: round rate divisions up
Hello,
[again dropped William Salmon and Jude Onyenegecha from Cc:]
On Thu, Sep 07, 2023 at 05:12:41PM +0100, Ben Dooks wrote:
> As suggested, round up the counter variables to ensure we
> always produce a longer period calculation.
>
> Reported-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
> Signed-off-by: Ben Dooks <ben.dooks@...ethink.co.uk>
> ---
> drivers/pwm/pwm-dwc-core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pwm/pwm-dwc-core.c b/drivers/pwm/pwm-dwc-core.c
> index 3b856685029d..6358e3345210 100644
> --- a/drivers/pwm/pwm-dwc-core.c
> +++ b/drivers/pwm/pwm-dwc-core.c
> @@ -50,13 +50,13 @@ static int __dwc_pwm_configure_timer(struct dwc_pwm *dwc,
> * 2^32 periods.
> */
> tmp = state->duty_cycle * dwc->clk_rate;
> - tmp = DIV_ROUND_CLOSEST_ULL(tmp, NSEC_PER_SEC);
> + tmp = DIV_ROUND_UP_ULL(tmp, NSEC_PER_SEC);
> if (tmp < 1 || tmp > (1ULL << 32))
> return -ERANGE;
> low = tmp - 1;
>
> tmp = (state->period - state->duty_cycle) * dwc->clk_rate;
> - tmp = DIV_ROUND_CLOSEST_ULL(tmp, NSEC_PER_SEC);
> + tmp = DIV_ROUND_UP_ULL(tmp, NSEC_PER_SEC);
> if (tmp < 1 || tmp > (1ULL << 32))
> return -ERANGE;
> high = tmp - 1;
Ah, I asked for that in the reply I just sent out to patch #4. Maybe move
this before the change from #4?! I think .get_state needs to be adapted
accoringly (to round up).
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists