[U-Boot] [PATCH] bugfix i.mx6 pwm: prevent overflow of period_c * duty_ns by casting duty_ns to ull first. This bug came up when trying to create a 200 Hz PWM.

Fabio Estevam festevam at gmail.com
Tue May 5 16:15:49 CEST 2015


Hi Brecht,

On Mon, Apr 27, 2015 at 9:11 AM, Brecht Neyrinck <bnrn at psicontrol.com> wrote:
> ---
>  drivers/pwm/pwm-imx-util.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>  mode change 100644 => 100755 drivers/pwm/pwm-imx-util.c
>
> diff --git a/drivers/pwm/pwm-imx-util.c b/drivers/pwm/pwm-imx-util.c
> index f1d0b35..777a8bf 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;

Your fix looks good, but your patch misses a Signed-off-by.

Also the commit log seems to be mixed with the subject.

Please check:
http://www.denx.de/wiki/U-Boot/Patches

You can also send it to the list using git send-email.

Regards,

Fabio Estevam


More information about the U-Boot mailing list