diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-03-05 20:56:05 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-03-11 16:48:51 -0400 |
commit | e9a15c8cad2a23e86a8e6457a3ab0ab3bda50d35 (patch) | |
tree | 12053f31464991a3c048afbef9286cba42dbc9fa /drivers/regulator | |
parent | 1c37f8a838fa8b1e98a984893bd4f1a8a9849421 (diff) |
regulator: wm8400: Use DIV_ROUND_UP macro to calculate selector
Use DIV_ROUND_UP macro for better readability.
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/wm8400-regulator.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index 706f39563a7b..8477153780b6 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c | |||
@@ -78,14 +78,14 @@ static int wm8400_ldo_set_voltage(struct regulator_dev *dev, | |||
78 | 78 | ||
79 | if (min_uV < 1700000) { | 79 | if (min_uV < 1700000) { |
80 | /* Steps of 50mV from 900mV; */ | 80 | /* Steps of 50mV from 900mV; */ |
81 | val = (min_uV - 850001) / 50000; | 81 | val = DIV_ROUND_UP(min_uV - 900000, 50000); |
82 | 82 | ||
83 | if ((val * 50000) + 900000 > max_uV) | 83 | if ((val * 50000) + 900000 > max_uV) |
84 | return -EINVAL; | 84 | return -EINVAL; |
85 | BUG_ON((val * 50000) + 900000 < min_uV); | 85 | BUG_ON((val * 50000) + 900000 < min_uV); |
86 | } else { | 86 | } else { |
87 | /* Steps of 100mV from 1700mV */ | 87 | /* Steps of 100mV from 1700mV */ |
88 | val = ((min_uV - 1600001) / 100000); | 88 | val = DIV_ROUND_UP(min_uV - 1700000, 100000); |
89 | 89 | ||
90 | if ((val * 100000) + 1700000 > max_uV) | 90 | if ((val * 100000) + 1700000 > max_uV) |
91 | return -EINVAL; | 91 | return -EINVAL; |
@@ -168,7 +168,7 @@ static int wm8400_dcdc_set_voltage(struct regulator_dev *dev, | |||
168 | if (min_uV < 850000) | 168 | if (min_uV < 850000) |
169 | return -EINVAL; | 169 | return -EINVAL; |
170 | 170 | ||
171 | val = (min_uV - 825001) / 25000; | 171 | val = DIV_ROUND_UP(min_uV - 850000, 25000); |
172 | 172 | ||
173 | if (850000 + (25000 * val) > max_uV) | 173 | if (850000 + (25000 * val) > max_uV) |
174 | return -EINVAL; | 174 | return -EINVAL; |