diff options
| author | Axel Lin <axel.lin@gmail.com> | 2012-03-05 20:54:22 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-03-11 16:48:52 -0400 |
| commit | 2fe4e0259dfd6d66f2a094b5109f11f8d253e764 (patch) | |
| tree | 604c97f242999d6a107465545cfea0dc85de6268 | |
| parent | ae76e8307ff2812a57692a54322c6898a949ae76 (diff) | |
regulator: tps65217: 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>
| -rw-r--r-- | drivers/regulator/tps65217-regulator.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 28a10eaeda17..15f2fa0bb005 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c | |||
| @@ -82,11 +82,11 @@ static int tps65217_uv_to_vsel1(int uV, unsigned int *vsel) | |||
| 82 | return -EINVAL; | 82 | return -EINVAL; |
| 83 | 83 | ||
| 84 | if (uV <= 1500000) | 84 | if (uV <= 1500000) |
| 85 | *vsel = (uV - 875001) / 25000; | 85 | *vsel = DIV_ROUND_UP(uV - 900000, 25000); |
| 86 | else if (uV <= 2900000) | 86 | else if (uV <= 2900000) |
| 87 | *vsel = 24 + (uV - 1450001) / 50000; | 87 | *vsel = 24 + DIV_ROUND_UP(uV - 1500000, 50000); |
| 88 | else if (uV < 3300000) | 88 | else if (uV < 3300000) |
| 89 | *vsel = 52 + (uV - 2800001) / 100000; | 89 | *vsel = 52 + DIV_ROUND_UP(uV - 2900000, 100000); |
| 90 | else | 90 | else |
| 91 | *vsel = 56; | 91 | *vsel = 56; |
| 92 | 92 | ||
| @@ -116,11 +116,11 @@ static int tps65217_uv_to_vsel2(int uV, unsigned int *vsel) | |||
| 116 | return -EINVAL; | 116 | return -EINVAL; |
| 117 | 117 | ||
| 118 | if (uV <= 1900000) | 118 | if (uV <= 1900000) |
| 119 | *vsel = (uV - 1450001) / 50000; | 119 | *vsel = DIV_ROUND_UP(uV - 1500000, 50000); |
| 120 | else if (uV <= 2400000) | 120 | else if (uV <= 2400000) |
| 121 | *vsel = 8 + (uV - 1800001) / 100000; | 121 | *vsel = 8 + DIV_ROUND_UP(uV - 1900000, 100000); |
| 122 | else | 122 | else |
| 123 | *vsel = 13 + (uV - 2350001) / 50000; | 123 | *vsel = 13 + DIV_ROUND_UP(uV - 2400000, 50000); |
| 124 | 124 | ||
| 125 | return 0; | 125 | return 0; |
| 126 | } | 126 | } |
