Skip to contentSkip to conversation

regulator: anatop: Fix wrong mask used in anatop_get_voltage_sel

PATCH Applied Axel Lin 2 participants 2 messages Jul 16, 2012 – Aug 1, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: anatop: Fix wrong mask used in anatop_get_voltage_sel

The mask used in anatop_get_voltage_sel does not match the mask used in anatop_set_voltage_sel.
We need to do left shift anatop_reg->vol_bit_shift bits for the correct mask.

---
 drivers/regulator/anatop-regulator.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/regulator/anatop-regulator.c +3 -2
index e9c2085..ce0fe72 100644
@@ -64,14 +64,15 @@ static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector)
 static int anatop_get_voltage_sel(struct regulator_dev *reg)
 {
 	struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
-	u32 val;
+	u32 val, mask;
 
 	if (!anatop_reg->control_reg)
 		return -ENOTSUPP;
 
 	val = anatop_read_reg(anatop_reg->mfd, anatop_reg->control_reg);
-	val = (val & ((1 << anatop_reg->vol_bit_width) - 1)) >>
+	mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
 		anatop_reg->vol_bit_shift;
+	val = (val & mask) >> anatop_reg->vol_bit_shift;
 
 	return val - anatop_reg->min_bit_val;
 }
Signature · 1 line
1.7.9.5
Applied
#1 lore raw
Quoted 3 lines · Axel Lin

The mask used in anatop_get_voltage_sel does not match the mask used in anatop_set_voltage_sel.
We need to do left shift anatop_reg->vol_bit_shift bits for the correct mask.

Applied, thanks.