All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [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.
Date: Tue, 28 Apr 2015 07:32:11 +0200	[thread overview]
Message-ID: <553F1B5B.2030603@denx.de> (raw)
In-Reply-To: <1430136666-18626-1-git-send-email-bnrn@psicontrol.com>

Hello Brecht Neyrinck,

Am 27.04.2015 14:11, schrieb Brecht Neyrinck:
> ---
>   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;

Thanks for this ... Hmm... this code is directly from linux
drivers/pwm/pwm-imx.c ... Do you have running a linux on your hw?
Could you verify this in linux too?

Thanks!

Acked-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>   	do_div(c, period_ns);
>   	*duty_c = c;
>
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2015-04-28  5:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 12:11 [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 Brecht Neyrinck
2015-04-28  5:32 ` Heiko Schocher [this message]
2015-05-05  8:40   ` NEYRINCK Brecht
2015-05-05 14:15 ` Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=553F1B5B.2030603@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.