Skip to contentSkip to conversation

regulator: wm831x-dcdc: Ensure selected voltage falls within requested range

PATCH Applied Axel Lin 2 participants 2 messages Nov 30, 2012 – Dec 2, 2012

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/regulator/wm831x-dcdc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/wm831x-dcdc.c +1 -1
index bce2565..96450f1 100644
@@ -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;
 
Signature · 1 line
1.7.9.5
Applied
#1 lore raw
Quoted 2 lines · Axel Lin

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

Applied, thanks.