Skip to content

Commit a336dc8

Browse files
AxelLinbroonie
authored andcommitted
regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
Use DIV_ROUND_UP to prevent truncation by integer division issue. This ensures we return enough delay time. Also fix returning negative value when new_sel < old_sel. Signed-off-by: Axel Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 9bc146a commit a336dc8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/regulator/da9052-regulator.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
250250
case DA9052_ID_BUCK3:
251251
case DA9052_ID_LDO2:
252252
case DA9052_ID_LDO3:
253-
ret = (new_sel - old_sel) * info->step_uV / 6250;
253+
ret = DIV_ROUND_UP(abs(new_sel - old_sel) * info->step_uV,
254+
6250);
254255
break;
255256
}
256257

0 commit comments

Comments
 (0)