mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-20 19:43:58 +08:00
pwm: omap-dmtimer: Round load and match values rather than truncate
When converting period and duty_cycle from nanoseconds to fclk cycles,
the error introduced by the integer division can be appreciable, especially
in the case of slow fclk or short period. Use DIV_ROUND_CLOSEST_ULL() so
that the error is kept to +/- 0.5 clock cycles.
Fixes: 6604c6556d
("pwm: Add PWM driver for OMAP using dual-mode timers")
Signed-off-by: David Rivshin <drivshin@allworx.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
parent
cd37888142
commit
7b0883f338
@ -49,11 +49,7 @@ to_pwm_omap_dmtimer_chip(struct pwm_chip *chip)
|
|||||||
|
|
||||||
static u32 pwm_omap_dmtimer_get_clock_cycles(unsigned long clk_rate, int ns)
|
static u32 pwm_omap_dmtimer_get_clock_cycles(unsigned long clk_rate, int ns)
|
||||||
{
|
{
|
||||||
u64 c = (u64)clk_rate * ns;
|
return DIV_ROUND_CLOSEST_ULL((u64)clk_rate * ns, NSEC_PER_SEC);
|
||||||
|
|
||||||
do_div(c, NSEC_PER_SEC);
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pwm_omap_dmtimer_start(struct pwm_omap_dmtimer_chip *omap)
|
static void pwm_omap_dmtimer_start(struct pwm_omap_dmtimer_chip *omap)
|
||||||
|
Loading…
Reference in New Issue
Block a user