Explorar o código

regulator: wm831x-dcdc: Ensure selected voltage falls within requested 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>
Axel Lin %!s(int64=12) %!d(string=hai) anos
pai
achega
1a679930e1
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      drivers/regulator/wm831x-dcdc.c

+ 1 - 1
drivers/regulator/wm831x-dcdc.c

@@ -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;