All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Gaetan Hug <ghug@induct.be>
Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shawn Guo <shawn.guo@linaro.org>,
	Fabio Estevam <fabio.estevam@freescale.com>
Subject: Re: [PATCH 1/1] fixing pwm-mxs period divider computation
Date: Wed, 18 Feb 2015 13:11:24 +0100	[thread overview]
Message-ID: <20150218121123.GB18576@ulmo> (raw)
In-Reply-To: <1424247536-16476-2-git-send-email-ghug@induct.be>

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]

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
> 

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-02-18 12:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18  8:18 [PATCH 0/1] fix for pwm-mxs period divider computation Gaetan Hug
2015-02-18  8:18 ` Gaetan Hug
2015-02-18  8:18 ` [PATCH 1/1] fixing " Gaetan Hug
2015-02-18  8:18   ` Gaetan Hug
2015-02-18 12:11   ` Thierry Reding [this message]
2015-02-18 12:08 ` [PATCH 0/1] fix for " Thierry Reding

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=20150218121123.GB18576@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=fabio.estevam@freescale.com \
    --cc=ghug@induct.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=shawn.guo@linaro.org \
    /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.