2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-16 01:04:08 +08:00

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 <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/20210618141412.4014912-1-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Axel Lin 2021-06-18 22:14:11 +08:00 committed by Mark Brown
parent 9bc146acc3
commit a336dc8f68
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -250,7 +250,8 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
case DA9052_ID_BUCK3:
case DA9052_ID_LDO2:
case DA9052_ID_LDO3:
ret = (new_sel - old_sel) * info->step_uV / 6250;
ret = DIV_ROUND_UP(abs(new_sel - old_sel) * info->step_uV,
6250);
break;
}