public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: da903x: Use DIV_ROUND_UP macro to calculate selector
@ 2012-03-05 22:54 Axel Lin
  2012-03-06 12:17 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-03-05 22:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: Eric Miao, Mike Rapoport, Liam Girdwood, Mark Brown

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/da903x.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 8dbc54d..1851f09 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -119,7 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
 		return -EINVAL;
 	}
 
-	val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
+	val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
 	*selector = val;
 	val <<= info->vol_shift;
 	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
@@ -202,7 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
 		return -EINVAL;
 	}
 
-	val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
+	val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
 	*selector = val;
 	val <<= info->vol_shift;
 	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
@@ -233,10 +233,10 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
 
 	thresh = (info->max_uV + info->min_uV) / 2;
 	if (min_uV < thresh) {
-		val = (thresh - min_uV + info->step_uV - 1) / info->step_uV;
+		val = DIV_ROUND_UP(thresh - min_uV, info->step_uV);
 		val |= 0x4;
 	} else {
-		val = (min_uV - thresh + info->step_uV - 1) / info->step_uV;
+		val = DIV_ROUND_UP(min_uV - thresh, info->step_uV);
 	}
 
 	*selector = val;
@@ -281,7 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
 		return -EINVAL;
 	}
 
-	val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
+	val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
 	*selector = val;
 	val <<= info->vol_shift;
 	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
@@ -307,7 +307,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
 		return -EINVAL;
 	}
 
-	val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV;
+	val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
 	val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val);
 	*selector = val;
 	val <<= info->vol_shift;
-- 
1.7.5.4




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

end of thread, other threads:[~2012-03-06 12:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-05 22:54 [PATCH] regulator: da903x: Use DIV_ROUND_UP macro to calculate selector Axel Lin
2012-03-06 12:17 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox