mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 02:04:05 +08:00
pwm: jz4740: Enhance precision in calculation of duty cycle
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>
This commit is contained in:
parent
b48d49e0d5
commit
9017dc4fbd
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user