Skip to content

Commit

Permalink
regulator: anatop: Fix wrong mask used in anatop_get_voltage_sel
Browse files Browse the repository at this point in the history
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: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Aug 7, 2012
1 parent 7f852e0 commit 3e2a928
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/regulator/anatop-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3e2a928

Please sign in to comment.