val is used as array index of ri->voltages. Thus the valid value range should be 0 .. ri->desc.n_voltages - 1. Signed-off-by: Axel Lin <axel.lin@gmail.com> --- drivers/regulator/tps6586x-regulator.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 8cff141..facd439 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c @@ -133,7 +133,7 @@ static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev) mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift; val = (val & mask) >> ri->volt_shift; - if (val > ri->desc.n_voltages) + if (val >= ri->desc.n_voltages) BUG(); return ri->voltages[val] * 1000; -- 1.7.0.4 --
The third parameter of tps6586x_set_bits() is the bit_mask, thus we should use (1 << ri->go_bit) instead of ri->go_bit. Signed-off-by: Axel Lin <axel.lin@gmail.com> --- drivers/regulator/tps6586x-regulator.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index facd439..51237fb 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c @@ -150,7 +150,7 @@ static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev, if (ret) return ret; - return tps6586x_set_bits(parent, ri->go_reg, ri->go_bit); + return tps6586x_set_bits(parent, ri->go_reg, 1 << ri->go_bit); } static int tps6586x_regulator_enable(struct regulator_dev *rdev) -- 1.7.0.4 --
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> but I'd be much happier if someone who actually has the hardware could verify that this is OK. --
I don't have the hardware handy at the moment. Gary, can you please verify the fix? -- Sincerely yours, Mike. --
Do we have any news on this testing ? I'd like to have these upstream for rc3. Thanks Liam -- Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk --
Sorry, I must have missed the original e-mail. I'll give it a try either later today or tomorrow, after I context-switch back to my dev system that uses the tps6586x driver. - Gary
The patch seems fine. - Gary ________________________________________ From: Liam Girdwood [lrg@slimlogic.co.uk] Sent: Wednesday, August 25, 2010 2:53 AM To: Mike Rapoport Cc: Mark Brown; Gary King; Axel Lin; linux-kernel Subject: Re: [PATCH 2/2] regulator: tps6586x-regulator - fix bit_mask parameter for tps6586x_set_bits() Do we have any news on this testing ? I'd like to have these upstream for rc3. Thanks Liam -- Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk --
Applied. Thanks Liam -- Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk --
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --
