[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20150218121123.GB18576@ulmo>
Date: Wed, 18 Feb 2015 13:11:24 +0100
From: Thierry Reding <thierry.reding@...il.com>
To: Gaetan Hug <ghug@...uct.be>
Cc: linux-pwm@...r.kernel.org, linux-kernel@...r.kernel.org,
Shawn Guo <shawn.guo@...aro.org>,
Fabio Estevam <fabio.estevam@...escale.com>
Subject: Re: [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
>
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists