Commit b2580877 authored by Brecht Neyrinck's avatar Brecht Neyrinck Committed by Stefano Babic

bugfix i.mx6 pwm: prevent overflow of period_c * duty_ns

Prevent overflow by casting duty_ns to ull first. This bug came up when trying to create a 200 Hz PWM
Signed-off-by: default avatarBrecht Neyrinck <bnrn@psicontrol.com>
Acked-by: Heiko Schocher<hs@denx.de>
parent 0e1f991e
......@@ -56,7 +56,7 @@ int pwm_imx_get_parms(int period_ns, int duty_ns, unsigned long *period_c,
*prescale = *period_c / 0x10000 + 1;
*period_c /= *prescale;
c = (unsigned long long)(*period_c * duty_ns);
c = *period_c * (unsigned long long)duty_ns;
do_div(c, period_ns);
*duty_c = c;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment