aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2021-06-18 22:14:11 +0800
committerMark Brown <broonie@kernel.org>2021-06-23 12:34:40 +0100
commita336dc8f683e5be794186b5643cd34cb28dd2c53 (patch)
tree95333d8b37822f21602b883c199fefe30c40af68 /drivers/regulator
parentregulator: hi6421v600: Fix setting wrong driver_data (diff)
downloadlinux-dev-a336dc8f683e5be794186b5643cd34cb28dd2c53.tar.xz
linux-dev-a336dc8f683e5be794186b5643cd34cb28dd2c53.zip
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>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/da9052-regulator.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index e18d291c7f21..23fa429ebe76 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -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;
}