diff options
author | Brecht Neyrinck <bnrn@psicontrol.com> | 2015-05-06 09:57:48 +0200 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2015-05-15 19:20:47 +0200 |
commit | b2580877b599f94730d8d174e0d83cb89217e2d6 (patch) | |
tree | ee3adaf700a5beb3bf0111dc321e1b157984b795 /drivers | |
parent | 0e1f991efb85520590fba6ad7955116a7bd499d4 (diff) | |
download | u-boot-b2580877b599f94730d8d174e0d83cb89217e2d6.zip u-boot-b2580877b599f94730d8d174e0d83cb89217e2d6.tar.gz u-boot-b2580877b599f94730d8d174e0d83cb89217e2d6.tar.bz2 |
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: Brecht Neyrinck <bnrn@psicontrol.com>
Acked-by: Heiko Schocher<hs@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pwm/pwm-imx-util.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/pwm/pwm-imx-util.c b/drivers/pwm/pwm-imx-util.c index f1d0b35..79d86028 100644 --- a/drivers/pwm/pwm-imx-util.c +++ b/drivers/pwm/pwm-imx-util.c @@ -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; |