Skip to content

Commit

Permalink
regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
Browse files Browse the repository at this point in the history
[ Upstream commit a336dc8 ]

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>
  • Loading branch information
AxelLin authored and gregkh committed Jul 14, 2021
1 parent 5d9e327 commit f0b8f56
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/regulator/da9052-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f0b8f56

Please sign in to comment.