linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
@ 2021-06-18 14:14 Axel Lin
  2021-06-18 14:14 ` [PATCH 2/2] regulator: da9052: Simplify checking DVC controlled regulators Axel Lin
  2021-06-23 16:08 ` (subset) [PATCH 1/2] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2021-06-18 14:14 UTC (permalink / raw)
  To: Mark Brown
  Cc: Philipp Zabel, Steve Twiss, Support Opensource, Liam Girdwood,
	linux-kernel, Axel Lin

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>
---
 drivers/regulator/da9052-regulator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-23 16:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 14:14 [PATCH 1/2] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Axel Lin
2021-06-18 14:14 ` [PATCH 2/2] regulator: da9052: Simplify checking DVC controlled regulators Axel Lin
2021-06-22 12:50   ` Mark Brown
2021-06-23 16:08 ` (subset) [PATCH 1/2] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).