Skip to contentSkip to conversation

regulator: tps6586x-regulator - fix value range checking for val

PATCH Applied Axel Lin 5 participants 9 messages Aug 22, 2010 – Aug 27, 2010 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 regulator: tps6586x-regulator - fix value range checking for val

val is used as array index of ri->voltages.
Thus the valid value range should be 0 .. ri->desc.n_voltages - 1.

---
 drivers/regulator/tps6586x-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/tps6586x-regulator.c +1 -1
index 8cff141..facd439 100644
@@ -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;
Signature · 1 line
1.7.0.4
author
#1 lore raw

PATCH 2/2 regulator: tps6586x-regulator - fix bit_mask parameter for tps6586x_set_bits()

The third parameter of tps6586x_set_bits() is the bit_mask, thus we should use (1 << ri->go_bit) instead of ri->go_bit.

---
 drivers/regulator/tps6586x-regulator.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/regulator/tps6586x-regulator.c +1 -1
index facd439..51237fb 100644
@@ -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)
Signature · 1 line
1.7.0.4
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] regulator: tps6586x-regulator - fix bit_mask parameter for tps6586x_set_bits()

In reply to Axel Lin
Quoted 4 lines · Axel Lin

The third parameter of tps6586x_set_bits() is the bit_mask, thus we should use (1 << ri->go_bit) instead of ri->go_bit.

but I'd be much happier if someone who actually has the hardware could verify that this is OK.

#3 lore raw

Re: [PATCH 2/2] regulator: tps6586x-regulator - fix bit_mask parameter for tps6586x_set_bits()

Quoted 10 lines · Mark Brown
Quoted 4 lines · Axel Lin

The third parameter of tps6586x_set_bits() is the bit_mask, thus we should use (1 << ri->go_bit) instead of ri->go_bit.

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?

Signature · 2 lines
Sincerely yours,
Mike.
#4 lore raw

Re: [PATCH 2/2] regulator: tps6586x-regulator - fix bit_mask parameter for tps6586x_set_bits()

Quoted 7 lines · Mike Rapoport
Quoted 6 lines · Mark Brown
Quoted 4 lines · Axel Lin

The third parameter of tps6586x_set_bits() is the bit_mask, thus we should use (1 << ri->go_bit) instead of ri->go_bit.

Quoted 8 lines
Quoted 4 lines

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?

Do we have any news on this testing ? I'd like to have these upstream for rc3.

Thanks

Liam

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#5 lore raw

Re: [PATCH 2/2] regulator: tps6586x-regulator - fix bit_mask parameter for tps6586x_set_bits()

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

Quoted 21 lines · Liam Girdwood
Quoted 7 lines · Mike Rapoport
Quoted 6 lines · Mark Brown
Quoted 4 lines · Axel Lin

The third parameter of tps6586x_set_bits() is the bit_mask, thus we should use (1 << ri->go_bit) instead of ri->go_bit.

Quoted 8 lines
Quoted 4 lines

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?

Do we have any news on this testing ? I'd like to have these upstream for rc3.

Quoted 8 lines

Thanks

Liam
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#6 lore raw

RE: [PATCH 2/2] regulator: tps6586x-regulator - fix bit_mask parameter for tps6586x_set_bits()

In reply to Liam Girdwood

The patch seems fine.

- Gary
________________________________________
From: Liam Girdwood [[email protected]]
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()

Quoted 7 lines · Mike Rapoport
Quoted 6 lines · Mark Brown
Quoted 4 lines · Axel Lin

The third parameter of tps6586x_set_bits() is the bit_mask, thus we should use (1 << ri->go_bit) instead of ri->go_bit.

Quoted 8 lines
Quoted 4 lines

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?

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

#7 lore raw

RE: [PATCH 2/2] regulator: tps6586x-regulator - fix bit_mask parameter for tps6586x_set_bits()

Quoted 23 lines · Gary King

The patch seems fine.

- Gary
________________________________________
From: Liam Girdwood [[email protected]]
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()

Quoted 12 lines · Mike Rapoport
Quoted 10 lines · Mark Brown
Quoted 4 lines · Axel Lin

The third parameter of tps6586x_set_bits() is the bit_mask, thus we should use (1 << ri->go_bit) instead of ri->go_bit.

but I'd be much happier if someone who actually has the hardware could verify that this is OK.

Quoted 7 lines
Quoted 3 lines

I don't have the hardware handy at the moment.
Gary, can you please verify the fix?

Do we have any news on this testing ? I'd like to have these upstream for rc3.

Applied.

Thanks

Liam

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk