diff options
author | Axel Lin <axel.lin@ingics.com> | 2021-06-18 17:14:11 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-14 17:55:56 +0300 |
commit | f0b8f5682db84d1e75b22dc62f14b114ce2917db (patch) | |
tree | 82d39244d9cec7161b5f639ba88a4ffe9677a238 /drivers/regulator | |
parent | 5d9e3279f5073a7048471b1797b5e02703499061 (diff) | |
download | linux-f0b8f5682db84d1e75b22dc62f14b114ce2917db.tar.xz |
regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
[ Upstream commit a336dc8f683e5be794186b5643cd34cb28dd2c53 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/da9052-regulator.c | 3 |
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; } |