regulator: wm831x-dcdc: Ensure selected voltage falls within requested range
authorAxel Lin <axel.lin@ingics.com>
Fri, 30 Nov 2012 05:19:33 +0000 (13:19 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sun, 2 Dec 2012 15:12:08 +0000 (00:12 +0900)
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>
drivers/regulator/wm831x-dcdc.c

index 782c228a19bd503ccda868ac67f46cce7fbba2e7..411cb12385aa3a5e159df2b0379a2e5685d3d1bf 100644 (file)
@@ -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;