lkml.org 
[lkml]   [2015]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] fixing pwm-mxs period divider computation
On Wed, Feb 18, 2015 at 09:18:56AM +0100, Gaetan Hug wrote:
> ---
> drivers/pwm/pwm-mxs.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)

Adding Shawn and Fabio, hence quoting the full patch.

> diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
> index f75ecb0..bbb2f8a 100644
> --- a/drivers/pwm/pwm-mxs.c
> +++ b/drivers/pwm/pwm-mxs.c
> @@ -52,15 +52,18 @@ static int mxs_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> unsigned long rate;
> unsigned long long c;
>
> + unsigned const int cdiv[PERIOD_CDIV_MAX] = {1, 2, 4, 8, 16, 64, 256, 1024};

This could prbably be static const and could be in file scope rather
than in this function.

Thierry

> +
> rate = clk_get_rate(mxs->clk);
> +
> while (1) {
> - c = rate / (1 << div);
> + c = rate / cdiv[div];
> c = c * period_ns;
> do_div(c, 1000000000);
> if (c < PERIOD_PERIOD_MAX)
> break;
> div++;
> - if (div > PERIOD_CDIV_MAX)
> + if (div >= PERIOD_CDIV_MAX)
> return -EINVAL;
> }
>
> --
> 1.7.10.4
>
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2015-02-18 13:21    [W:0.198 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site