mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel@vger.kernel.org, Liam Girdwood <lrg@ti.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: Re: [PATCH] regulator: Simplify the code to get selector in isl6271a_set_voltage
Date: Fri, 2 Mar 2012 11:13:11 +0100	[thread overview]
Message-ID: <201203021113.11269.marek.vasut@gmail.com> (raw)
In-Reply-To: <1330651142.6247.1.camel@phoenix>

> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/regulator/isl6271a-regulator.c |   14 +++-----------
>  1 files changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/regulator/isl6271a-regulator.c
> b/drivers/regulator/isl6271a-regulator.c index c1a456c..775f5fd 100644
> --- a/drivers/regulator/isl6271a-regulator.c
> +++ b/drivers/regulator/isl6271a-regulator.c
> @@ -63,23 +63,15 @@ static int isl6271a_set_voltage(struct regulator_dev
> *dev, unsigned *selector)
>  {
>  	struct isl_pmic *pmic = rdev_get_drvdata(dev);
> -	int vsel, err, data;
> +	int err, data;
> 
>  	if (minuV < ISL6271A_VOLTAGE_MIN || minuV > ISL6271A_VOLTAGE_MAX)
>  		return -EINVAL;
>  	if (maxuV < ISL6271A_VOLTAGE_MIN || maxuV > ISL6271A_VOLTAGE_MAX)
>  		return -EINVAL;
> 
> -	/* Align to 50000 mV */

Heh ... 50000mV ? :-)

> -	vsel = minuV - (minuV % ISL6271A_VOLTAGE_STEP);
> -
> -	/* If the result fell out of [minuV,maxuV] range, put it back */
> -	if (vsel < minuV)
> -		vsel += ISL6271A_VOLTAGE_STEP;
> -
> -	/* Convert the microvolts to data for the chip */
> -	data = (vsel - ISL6271A_VOLTAGE_MIN) / ISL6271A_VOLTAGE_STEP;
> -
> +	data = DIV_ROUND_UP(minuV - ISL6271A_VOLTAGE_MIN,
> +			    ISL6271A_VOLTAGE_STEP);

Ok, this makes sense.

Acked-by: Marek Vasut <marek.vasut@gmail.com>

>  	*selector = data;
> 
>  	mutex_lock(&pmic->mtx);

  reply	other threads:[~2012-03-02 10:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-02  1:19 Axel Lin
2012-03-02 10:13 ` Marek Vasut [this message]
2012-03-02 11:23 ` Mark Brown

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=201203021113.11269.marek.vasut@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=axel.lin@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome