bugfix i.mx6 pwm: prevent overflow of period_c * duty_ns
Subsystems (2)
PATCH 1/1 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
--- drivers/pwm/pwm-imx-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-imx-util.c +1 -1
@@ -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;
Signature · 14 lines
1.8.2.3 **** DISCLAIMER **** The contents of this e-mail are intended for the named addressee only. It contains information which may be confidential and which may also be privileged. Unless you are the named addressee (or authorised to receive for the addressee) you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. Further, we make every effort to keep our network free from viruses. However, you do need to verify that this email and any attachments are free of viruses as we can take no responsibility for any computer virus which might be transferred by way of this e-mail.
PATCH 1/1 bugfix i.mx6 pwm: prevent overflow of period_c * duty_ns
Hello Brecht Neyrinck,
Am 06.05.2015 09:57, schrieb Brecht Neyrinck:
Quoted 6 lines
Prevent overflow by casting
duty_nsto ull first. This bug came up when trying to create a 200 Hz PWMSigned-off-by Brecht Neyrinck <[email protected]>--- drivers/pwm/pwm-imx-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks!
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 1/1 bugfix i.mx6 pwm: prevent overflow of period_c * duty_ns
In reply to Brecht NeyrinckQuoted 12 lines · Brecht Neyrinck
Prevent overflow by casting
duty_nsto ull first. This bug came up when trying to create a 200 Hz PWMSigned-off-by Brecht Neyrinck <[email protected]>--- drivers/pwm/pwm-imx-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pwm/pwm-imx-util.c +0
-0
drivers/pwm/pwm-imx-util.c int pwm_imx_get_parms(int period_ns, int duty_ns, unsigned long *period_c, · line 62
Quoted 8 lines
drivers/pwm/pwm-imx-util.c +1
-1@@ -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;
Applied to u-boot-imx, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================