aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-03-05 17:54:40 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-03-11 16:48:52 -0400
commitae76e8307ff2812a57692a54322c6898a949ae76 (patch)
tree1ec8b2faa9a78a07a42b9636abca5eeecf9642d6 /drivers/regulator
parente9a15c8cad2a23e86a8e6457a3ab0ab3bda50d35 (diff)
regulator: da903x: Use DIV_ROUND_UP macro to calculate selector
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/da903x.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 8dbc54da7d70..1851f0929ef0 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,
119 return -EINVAL; 119 return -EINVAL;
120 } 120 }
121 121
122 val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; 122 val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
123 *selector = val; 123 *selector = val;
124 val <<= info->vol_shift; 124 val <<= info->vol_shift;
125 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; 125 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
@@ -202,7 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
202 return -EINVAL; 202 return -EINVAL;
203 } 203 }
204 204
205 val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; 205 val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
206 *selector = val; 206 *selector = val;
207 val <<= info->vol_shift; 207 val <<= info->vol_shift;
208 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; 208 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
@@ -233,10 +233,10 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
233 233
234 thresh = (info->max_uV + info->min_uV) / 2; 234 thresh = (info->max_uV + info->min_uV) / 2;
235 if (min_uV < thresh) { 235 if (min_uV < thresh) {
236 val = (thresh - min_uV + info->step_uV - 1) / info->step_uV; 236 val = DIV_ROUND_UP(thresh - min_uV, info->step_uV);
237 val |= 0x4; 237 val |= 0x4;
238 } else { 238 } else {
239 val = (min_uV - thresh + info->step_uV - 1) / info->step_uV; 239 val = DIV_ROUND_UP(min_uV - thresh, info->step_uV);
240 } 240 }
241 241
242 *selector = val; 242 *selector = val;
@@ -281,7 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
281 return -EINVAL; 281 return -EINVAL;
282 } 282 }
283 283
284 val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; 284 val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
285 *selector = val; 285 *selector = val;
286 val <<= info->vol_shift; 286 val <<= info->vol_shift;
287 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; 287 mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
@@ -307,7 +307,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
307 return -EINVAL; 307 return -EINVAL;
308 } 308 }
309 309
310 val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; 310 val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
311 val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val); 311 val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val);
312 *selector = val; 312 *selector = val;
313 val <<= info->vol_shift; 313 val <<= info->vol_shift;