Skip to content

Commit

Permalink
regulator: wm831x-dcdc: Ensure selected voltage falls within requeste…
Browse files Browse the repository at this point in the history
…d range

Use DIV_ROUND_UP to ensure selected voltage won't less than min_uV due to
integer truncation.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Dec 2, 2012
1 parent 9489e9d commit 1a67993
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/regulator/wm831x-dcdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static int wm831x_buckv_map_voltage(struct regulator_dev *rdev,
if (min_uV < 600000)
vsel = 0;
else if (min_uV <= 1800000)
vsel = ((min_uV - 600000) / 12500) + 8;
vsel = DIV_ROUND_UP(min_uV - 600000, 12500) + 8;
else
return -EINVAL;

Expand Down

0 comments on commit 1a67993

Please sign in to comment.