public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robin Gong <b38343@freescale.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFT] regulator: pfuze100: Fix n_voltages setting for SW2~SW4 with high bit set
Date: Tue, 30 Jul 2013 11:23:11 +0800	[thread overview]
Message-ID: <20130730032310.GC1430@Robin-OptiPlex-780> (raw)
In-Reply-To: <1375152388.4265.1.camel@phoenix>

Ok for me.
On Tue, Jul 30, 2013 at 10:46:28AM +0800, Axel Lin wrote:
> Current code adjust min_uV and uV_step but missed adjusting the n_voltages
> setting.
> 
> When BIT6 is clear:
>         n_voltages = (1975000 - 400000) / 25000 + 1 = 64
> When BIT6 is set:
>         n_voltages = (3300000 - 800000) / 50000 + 1 = 51
> 
> The n_voltages needs update because when BIT6 is set 0x73 ~ 0x7f are reserved.
> When using regulator_list_voltage_linear, the n_voltages does matter here
> because wrong n_voltages setting make the equation return wrong result.
> e.g. if selector is 63, regulator_list_voltage_linear returns
>      800000 + (50000 * 63) = 4000000
>      It should return -EINVAL if the selector is in the range of 51 ~ 63.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/regulator/pfuze100-regulator.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
> index 2dadc31..a77379b 100644
> --- a/drivers/regulator/pfuze100-regulator.c
> +++ b/drivers/regulator/pfuze100-regulator.c
> @@ -387,8 +387,11 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
>  
>  	for (i = 0; i < PFUZE100_MAX_REGULATOR; i++) {
>  		struct regulator_init_data *init_data;
> +		struct regulator_desc *desc;
>  		int val;
>  
> +		desc = &pfuze_chip->regulator_descs[i].desc;
> +
>  		if (pdata)
>  			init_data = pdata->init_data[i];
>  		else
> @@ -396,13 +399,11 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
>  
>  		/* SW2~SW4 high bit check and modify the voltage value table */
>  		if (i > PFUZE100_SW1C && i < PFUZE100_SWBST) {
> -			regmap_read(pfuze_chip->regmap, PFUZE100_SW2VOL +
> -					(i - PFUZE100_SW2) * 7, &val);
> +			regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val);
>  			if (val & 0x40) {
> -				pfuze_chip->regulator_descs[i].desc.min_uV
> -				= 800000;
> -				pfuze_chip->regulator_descs[i].desc.uV_step
> -				= 50000;
> +				desc->min_uV = 800000;
> +				desc->uV_step = 50000;
> +				desc->n_voltages = 51;
>  			}
>  		}
>  
> @@ -411,8 +412,7 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
>  		config.driver_data = pfuze_chip;
>  		config.of_node = match_of_node(i);
>  
> -		pfuze_chip->regulators[i] = regulator_register(&pfuze_chip
> -			->regulator_descs[i].desc, &config);
> +		pfuze_chip->regulators[i] = regulator_register(desc, &config);
>  		if (IS_ERR(pfuze_chip->regulators[i])) {
>  			dev_err(&client->dev, "register regulator%s failed\n",
>  				pfuze100_regulators[i].desc.name);
> -- 
> 1.8.1.2
> 
> 
> 
> 


  reply	other threads:[~2013-07-30  3:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30  2:46 [PATCH RFT] regulator: pfuze100: Fix n_voltages setting for SW2~SW4 with high bit set Axel Lin
2013-07-30  3:23 ` Robin Gong [this message]
2013-07-30 10:21   ` Mark Brown
2013-07-30 10:54     ` Robin Gong
2013-07-30 10:21 ` 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=20130730032310.GC1430@Robin-OptiPlex-780 \
    --to=b38343@freescale.com \
    --cc=axel.lin@ingics.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox