All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: "'Axel Lin'" <axel.lin@gmail.com>, linux-kernel@vger.kernel.org
Cc: "'Kyungmin Park'" <kyungmin.park@samsung.com>,
	"'Liam Girdwood'" <lrg@ti.com>,
	"'Mark Brown'" <broonie@opensource.wolfsonmicro.com>
Subject: RE: [PATCH 1/2] regulator: Convert lp3971 to set_voltage_sel
Date: Mon, 26 Mar 2012 11:19:36 +0200	[thread overview]
Message-ID: <000301cd0b31$9081c860$b1855920$%szyprowski@samsung.com> (raw)
In-Reply-To: <1332470994.13074.2.camel@phoenix>

Hello,

On Friday, March 23, 2012 3:50 AM Axel Lin wrote:

> Signed-off-by: Axel Lin <axel.lin@gmail.com>

The patch looks good, but I don't have access to the hardware to test it.

Acked-By: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>  drivers/regulator/lp3971.c |   58 +++++++++++--------------------------------
>  1 files changed, 15 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
> index 0cfabd3..49bcdb0 100644
> --- a/drivers/regulator/lp3971.c
> +++ b/drivers/regulator/lp3971.c
> @@ -124,6 +124,10 @@ static const int *ldo_voltage_map[] = {
>  static int lp3971_ldo_list_voltage(struct regulator_dev *dev, unsigned index)
>  {
>  	int ldo = rdev_get_id(dev) - LP3971_LDO1;
> +
> +	if (index > LDO_VOL_MAX_IDX)
> +		return -EINVAL;
> +
>  	return 1000 * LDO_VOL_VALUE_MAP(ldo)[index];
>  }
> 
> @@ -168,32 +172,15 @@ static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
>  	return 1000 * LDO_VOL_VALUE_MAP(ldo)[val];
>  }
> 
> -static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
> -				  int min_uV, int max_uV,
> -				  unsigned int *selector)
> +static int lp3971_ldo_set_voltage_sel(struct regulator_dev *dev,
> +				      unsigned int selector)
>  {
>  	struct lp3971 *lp3971 = rdev_get_drvdata(dev);
>  	int ldo = rdev_get_id(dev) - LP3971_LDO1;
> -	int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
> -	const int *vol_map = LDO_VOL_VALUE_MAP(ldo);
> -	u16 val;
> -
> -	if (min_vol < vol_map[LDO_VOL_MIN_IDX] ||
> -	    min_vol > vol_map[LDO_VOL_MAX_IDX])
> -		return -EINVAL;
> -
> -	for (val = LDO_VOL_MIN_IDX; val <= LDO_VOL_MAX_IDX; val++)
> -		if (vol_map[val] >= min_vol)
> -			break;
> -
> -	if (val > LDO_VOL_MAX_IDX || vol_map[val] > max_vol)
> -		return -EINVAL;
> -
> -	*selector = val;
> 
>  	return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo),
>  			LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo),
> -			val << LDO_VOL_CONTR_SHIFT(ldo));
> +			selector << LDO_VOL_CONTR_SHIFT(ldo));
>  }
> 
>  static struct regulator_ops lp3971_ldo_ops = {
> @@ -202,11 +189,14 @@ static struct regulator_ops lp3971_ldo_ops = {
>  	.enable = lp3971_ldo_enable,
>  	.disable = lp3971_ldo_disable,
>  	.get_voltage = lp3971_ldo_get_voltage,
> -	.set_voltage = lp3971_ldo_set_voltage,
> +	.set_voltage_sel = lp3971_ldo_set_voltage_sel,
>  };
> 
>  static int lp3971_dcdc_list_voltage(struct regulator_dev *dev, unsigned index)
>  {
> +	if (index < BUCK_TARGET_VOL_MIN_IDX || index > BUCK_TARGET_VOL_MAX_IDX)
> +		return -EINVAL;
> +
>  	return 1000 * buck_voltage_map[index];
>  }
> 
> @@ -259,33 +249,15 @@ static int lp3971_dcdc_get_voltage(struct regulator_dev *dev)
>  	return val;
>  }
> 
> -static int lp3971_dcdc_set_voltage(struct regulator_dev *dev,
> -				   int min_uV, int max_uV,
> -				   unsigned int *selector)
> +static int lp3971_dcdc_set_voltage_sel(struct regulator_dev *dev,
> +				       unsigned int selector)
>  {
>  	struct lp3971 *lp3971 = rdev_get_drvdata(dev);
>  	int buck = rdev_get_id(dev) - LP3971_DCDC1;
> -	int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
> -	const int *vol_map = buck_voltage_map;
> -	u16 val;
>  	int ret;
> 
> -	if (min_vol < vol_map[BUCK_TARGET_VOL_MIN_IDX] ||
> -	    min_vol > vol_map[BUCK_TARGET_VOL_MAX_IDX])
> -		return -EINVAL;
> -
> -	for (val = BUCK_TARGET_VOL_MIN_IDX; val <= BUCK_TARGET_VOL_MAX_IDX;
> -	     val++)
> -		if (vol_map[val] >= min_vol)
> -			break;
> -
> -	if (val > BUCK_TARGET_VOL_MAX_IDX || vol_map[val] > max_vol)
> -		return -EINVAL;
> -
> -	*selector = val;
> -
>  	ret = lp3971_set_bits(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck),
> -	       BUCK_TARGET_VOL_MASK, val);
> +	       BUCK_TARGET_VOL_MASK, selector);
>  	if (ret)
>  		return ret;
> 
> @@ -306,7 +278,7 @@ static struct regulator_ops lp3971_dcdc_ops = {
>  	.enable = lp3971_dcdc_enable,
>  	.disable = lp3971_dcdc_disable,
>  	.get_voltage = lp3971_dcdc_get_voltage,
> -	.set_voltage = lp3971_dcdc_set_voltage,
> +	.set_voltage_sel = lp3971_dcdc_set_voltage_sel,
>  };
> 
>  static struct regulator_desc regulators[] = {
> --
> 1.7.5.4
> 

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center



      parent reply	other threads:[~2012-03-26  9:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-23  2:49 [PATCH 1/2] regulator: Convert lp3971 to set_voltage_sel Axel Lin
2012-03-23  2:51 ` [PATCH 2/2] regulator: Convert lp3972 " Axel Lin
2012-03-26  9:19 ` Marek Szyprowski [this message]

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='000301cd0b31$9081c860$b1855920$%szyprowski@samsung.com' \
    --to=m.szyprowski@samsung.com \
    --cc=axel.lin@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=kyungmin.park@samsung.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 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.