public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@ti.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel
Date: Tue, 11 Dec 2012 08:16:44 +0100	[thread overview]
Message-ID: <50C6DDDC.7070208@samsung.com> (raw)
In-Reply-To: <1355140012.6601.1.camel@phoenix>

Hello,

On 12/10/2012 12:46 PM, Axel Lin wrote:
> regulator_list_voltage_table() returns -EINVAL if selector >= n_voltages.
> Thus we don't need to check if reg is greater than BUCK_TARGET_VOL_MAX_IDX in
> lp3971_dcdc_get_voltage_sel.
>
> BUCK_TARGET_VOL_MIN_IDX and BUCK_TARGET_VOL_MAX_IDX are not used, remove them.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

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

> ---
>   drivers/regulator/lp3971.c |   22 ++++++----------------
>   1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
> index 5f68ff1..9cb2c0f 100644
> --- a/drivers/regulator/lp3971.c
> +++ b/drivers/regulator/lp3971.c
> @@ -73,8 +73,6 @@ static const unsigned int buck_voltage_map[] = {
>   };
>
>   #define BUCK_TARGET_VOL_MASK 0x3f
> -#define BUCK_TARGET_VOL_MIN_IDX 0x01
> -#define BUCK_TARGET_VOL_MAX_IDX 0x19
>
>   #define LP3971_BUCK_RAMP_REG(x)	(buck_base_addr[x]+2)
>
> @@ -140,7 +138,7 @@ static int lp3971_ldo_disable(struct regulator_dev *dev)
>   	return lp3971_set_bits(lp3971, LP3971_LDO_ENABLE_REG, mask, 0);
>   }
>
> -static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
> +static int lp3971_ldo_get_voltage_sel(struct regulator_dev *dev)
>   {
>   	struct lp3971 *lp3971 = rdev_get_drvdata(dev);
>   	int ldo = rdev_get_id(dev) - LP3971_LDO1;
> @@ -149,7 +147,7 @@ static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
>   	reg = lp3971_reg_read(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo));
>   	val = (reg >> LDO_VOL_CONTR_SHIFT(ldo)) & LDO_VOL_CONTR_MASK;
>
> -	return dev->desc->volt_table[val];
> +	return val;
>   }
>
>   static int lp3971_ldo_set_voltage_sel(struct regulator_dev *dev,
> @@ -168,7 +166,7 @@ static struct regulator_ops lp3971_ldo_ops = {
>   	.is_enabled = lp3971_ldo_is_enabled,
>   	.enable = lp3971_ldo_enable,
>   	.disable = lp3971_ldo_disable,
> -	.get_voltage = lp3971_ldo_get_voltage,
> +	.get_voltage_sel = lp3971_ldo_get_voltage_sel,
>   	.set_voltage_sel = lp3971_ldo_set_voltage_sel,
>   };
>
> @@ -201,24 +199,16 @@ static int lp3971_dcdc_disable(struct regulator_dev *dev)
>   	return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_ENABLE_REG, mask, 0);
>   }
>
> -static int lp3971_dcdc_get_voltage(struct regulator_dev *dev)
> +static int lp3971_dcdc_get_voltage_sel(struct regulator_dev *dev)
>   {
>   	struct lp3971 *lp3971 = rdev_get_drvdata(dev);
>   	int buck = rdev_get_id(dev) - LP3971_DCDC1;
>   	u16 reg;
> -	int val;
>
>   	reg = lp3971_reg_read(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck));
>   	reg &= BUCK_TARGET_VOL_MASK;
>
> -	if (reg <= BUCK_TARGET_VOL_MAX_IDX)
> -		val = buck_voltage_map[reg];
> -	else {
> -		val = 0;
> -		dev_warn(&dev->dev, "chip reported incorrect voltage value.\n");
> -	}
> -
> -	return val;
> +	return reg;
>   }
>
>   static int lp3971_dcdc_set_voltage_sel(struct regulator_dev *dev,
> @@ -249,7 +239,7 @@ static struct regulator_ops lp3971_dcdc_ops = {
>   	.is_enabled = lp3971_dcdc_is_enabled,
>   	.enable = lp3971_dcdc_enable,
>   	.disable = lp3971_dcdc_disable,
> -	.get_voltage = lp3971_dcdc_get_voltage,
> +	.get_voltage_sel = lp3971_dcdc_get_voltage_sel,
>   	.set_voltage_sel = lp3971_dcdc_set_voltage_sel,
>   };
>
>


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


  parent reply	other threads:[~2012-12-11  7:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-10 11:46 [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel Axel Lin
2012-12-10 11:50 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
2012-12-24 16:28   ` Mark Brown
2012-12-11  7:16 ` Marek Szyprowski [this message]
2012-12-24 16:27 ` [PATCH 1/2] regulator: lp3971: " 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=50C6DDDC.7070208@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=axel.lin@ingics.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