Patchwork [39/74] regulator: max8998: Ensure enough delay time for max8998_set_voltage_buck_time_sel

login
register
mail settings
Submitter Herton Ronaldo Krzesinski
Date Jan. 24, 2013, 3:26 a.m.
Message ID <1358998046-613-40-git-send-email-herton.krzesinski@canonical.com>
Download mbox | patch
Permalink /patch/215152/
State New
Headers show

Comments

Herton Ronaldo Krzesinski - Jan. 24, 2013, 3:26 a.m.
3.5.7.4 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Axel Lin <axel.lin@ingics.com>

commit 81d0a6ae7befb24c06f4aa4856af7f8d1f612171 upstream.

Use DIV_ROUND_UP to prevent truncation by integer division issue.
This ensures we return enough delay time.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
---
 drivers/regulator/max8998.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 5e56df0..b3b2984 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -447,7 +447,7 @@  static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev,
 
 	difference = (new_selector - old_selector) * desc->step / 1000;
 	if (difference > 0)
-		return difference / ((val & 0x0f) + 1);
+		return DIV_ROUND_UP(difference, (val & 0x0f) + 1);
 
 	return 0;
 }