* [PATCH v3 2/4] pwm: jz4740: Enhance precision in calculation of duty cycle [not found] <20200527115225.10069-1-paul@crapouillou.net> @ 2020-05-27 11:52 ` Paul Cercueil 2020-05-28 14:41 ` Sasha Levin 0 siblings, 1 reply; 2+ messages in thread From: Paul Cercueil @ 2020-05-27 11:52 UTC (permalink / raw) To: Thierry Reding, Uwe Kleine-König Cc: od, linux-pwm, linux-kernel, Paul Cercueil, stable Calculating the hardware value for the duty from the hardware value of the period resulted in a precision loss versus calculating it from the clock rate directly. (Also remove a cast that doesn't really need to be here) Fixes: f6b8a5700057 ("pwm: Add Ingenic JZ4740 support") Cc: <stable@vger.kernel.org> Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Paul Cercueil <paul@crapouillou.net> --- Notes: v2: New patch. I don't consider this a fix but an enhancement, since the old behaviour was in place since the driver was born in ~2010, so no Fixes tag. v3: Add Fixes tag and Uwe's Reviewed-by drivers/pwm/pwm-jz4740.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index 3cd5c054ad9a..4fe9d99ac9a9 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -158,11 +158,11 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, /* Calculate period value */ tmp = (unsigned long long)rate * state->period; do_div(tmp, NSEC_PER_SEC); - period = (unsigned long)tmp; + period = tmp; /* Calculate duty value */ - tmp = (unsigned long long)period * state->duty_cycle; - do_div(tmp, state->period); + tmp = (unsigned long long)rate * state->duty_cycle; + do_div(tmp, NSEC_PER_SEC); duty = period - tmp; if (duty >= period) -- 2.26.2 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3 2/4] pwm: jz4740: Enhance precision in calculation of duty cycle 2020-05-27 11:52 ` [PATCH v3 2/4] pwm: jz4740: Enhance precision in calculation of duty cycle Paul Cercueil @ 2020-05-28 14:41 ` Sasha Levin 0 siblings, 0 replies; 2+ messages in thread From: Sasha Levin @ 2020-05-28 14:41 UTC (permalink / raw) To: Sasha Levin, Paul Cercueil, Thierry Reding; +Cc: od, linux-pwm, stable, stable Hi [This is an automated email] This commit has been processed because it contains a "Fixes:" tag fixing commit: f6b8a5700057 ("pwm: Add Ingenic JZ4740 support"). The bot has tested the following trees: v5.6.14, v5.4.42, v4.19.124, v4.14.181, v4.9.224, v4.4.224. v5.6.14: Failed to apply! Possible dependencies: 485b56f08f33 ("pwm: jz4740: Improve algorithm of clock calculation") ce1f9cece057 ("pwm: jz4740: Use clocks from TCU driver") v5.4.42: Failed to apply! Possible dependencies: 485b56f08f33 ("pwm: jz4740: Improve algorithm of clock calculation") ce1f9cece057 ("pwm: jz4740: Use clocks from TCU driver") v4.19.124: Failed to apply! Possible dependencies: 1ac99c58bda9 ("pwm: jz4740: Apply configuration atomically") 485b56f08f33 ("pwm: jz4740: Improve algorithm of clock calculation") ce1f9cece057 ("pwm: jz4740: Use clocks from TCU driver") v4.14.181: Failed to apply! Possible dependencies: 174dcc8eaec5 ("pwm: jz4740: Implement ->set_polarity()") 1ac99c58bda9 ("pwm: jz4740: Apply configuration atomically") 485b56f08f33 ("pwm: jz4740: Improve algorithm of clock calculation") b419006275db ("pwm: jz4740: Enable for all Ingenic SoCs") ce1f9cece057 ("pwm: jz4740: Use clocks from TCU driver") v4.9.224: Failed to apply! Possible dependencies: 174dcc8eaec5 ("pwm: jz4740: Implement ->set_polarity()") 1ac99c58bda9 ("pwm: jz4740: Apply configuration atomically") 485b56f08f33 ("pwm: jz4740: Improve algorithm of clock calculation") b419006275db ("pwm: jz4740: Enable for all Ingenic SoCs") ce1f9cece057 ("pwm: jz4740: Use clocks from TCU driver") v4.4.224: Failed to apply! Possible dependencies: 174dcc8eaec5 ("pwm: jz4740: Implement ->set_polarity()") 1ac99c58bda9 ("pwm: jz4740: Apply configuration atomically") 485b56f08f33 ("pwm: jz4740: Improve algorithm of clock calculation") b419006275db ("pwm: jz4740: Enable for all Ingenic SoCs") ce1f9cece057 ("pwm: jz4740: Use clocks from TCU driver") NOTE: The patch will not be queued to stable trees until it is upstream. How should we proceed with this patch? -- Thanks Sasha ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-28 14:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20200527115225.10069-1-paul@crapouillou.net>
2020-05-27 11:52 ` [PATCH v3 2/4] pwm: jz4740: Enhance precision in calculation of duty cycle Paul Cercueil
2020-05-28 14:41 ` Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).