projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9bc146a
)
regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
author
Axel Lin
<axel.lin@ingics.com>
Fri, 18 Jun 2021 14:14:11 +0000
(22:14 +0800)
committer
Mark Brown
<broonie@kernel.org>
Wed, 23 Jun 2021 11:34:40 +0000
(12:34 +0100)
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>
drivers/regulator/da9052-regulator.c
patch
|
blob
|
history
diff --git
a/drivers/regulator/da9052-regulator.c
b/drivers/regulator/da9052-regulator.c
index e18d291c7f21c75ed9764985e09d1fe7fc1e292a..23fa429ebe760d71939624f7e017c50e2d89413a 100644
(file)
--- 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;
}