mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-13 22:25:03 +00:00
pwm: jz4740: Enhance precision in calculation of duty cycle
commit9017dc4fbd
upstream. 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:f6b8a57000
("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> Signed-off-by: Thierry Reding <thierry.reding@gmail.com> [ukl: backport to v5.4.y and adapt commit log accordingly] Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d0da4be602
commit
a6030d71e6
1 changed files with 2 additions and 2 deletions
|
@ -108,8 +108,8 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
|||
if (prescaler == 6)
|
||||
return -EINVAL;
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue