[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210618141412.4014912-1-axel.lin@ingics.com>
Date: Fri, 18 Jun 2021 22:14:11 +0800
From: Axel Lin <axel.lin@...ics.com>
To: Mark Brown <broonie@...nel.org>
Cc: Philipp Zabel <p.zabel@...gutronix.de>,
Steve Twiss <stwiss.opensource@...semi.com>,
Support Opensource <support.opensource@...semi.com>,
Liam Girdwood <lgirdwood@...il.com>,
linux-kernel@...r.kernel.org, Axel Lin <axel.lin@...ics.com>
Subject: [PATCH 1/2] 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@...ics.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
Powered by blists - more mailing lists