Commit 3e2a9284 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

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.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 7f852e05
...@@ -64,14 +64,15 @@ static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector) ...@@ -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) static int anatop_get_voltage_sel(struct regulator_dev *reg)
{ {
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
u32 val; u32 val, mask;
if (!anatop_reg->control_reg) if (!anatop_reg->control_reg)
return -ENOTSUPP; return -ENOTSUPP;
val = anatop_read_reg(anatop_reg->mfd, anatop_reg->control_reg); 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; anatop_reg->vol_bit_shift;
val = (val & mask) >> anatop_reg->vol_bit_shift;
return val - anatop_reg->min_bit_val; return val - anatop_reg->min_bit_val;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment