diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-12 04:34:55 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-13 05:47:02 -0400 |
commit | 38c20eb23fb7b5505ac80595f18f4209abc19cd3 (patch) | |
tree | e5359e02888a3ce9166d66ddc199eba23aff9d0c /drivers/regulator/wm8400-regulator.c | |
parent | 3fe3a182adfeca84f39751af03c8571831a0877f (diff) |
regulator: wm8400: Use wm8400_ldo_list_voltage instead of open code to verify selected voltage
Call wm8400_ldo_list_voltage() instead of open code to verify selected voltage
falls within specified range.
Use wm8400_ldo_list_voltage() here is less error prone.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/wm8400-regulator.c')
-rw-r--r-- | drivers/regulator/wm8400-regulator.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index f365795d51c2..9f9df8eef1a1 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c | |||
@@ -35,27 +35,19 @@ static int wm8400_ldo_map_voltage(struct regulator_dev *dev, | |||
35 | int min_uV, int max_uV) | 35 | int min_uV, int max_uV) |
36 | { | 36 | { |
37 | u16 val; | 37 | u16 val; |
38 | int volt; | ||
38 | 39 | ||
39 | if (min_uV < 900000 || min_uV > 3300000) | 40 | if (min_uV < 900000 || min_uV > 3300000) |
40 | return -EINVAL; | 41 | return -EINVAL; |
41 | 42 | ||
42 | if (min_uV < 1700000) { | 43 | if (min_uV < 1700000) /* Steps of 50mV from 900mV; */ |
43 | /* Steps of 50mV from 900mV; */ | ||
44 | val = DIV_ROUND_UP(min_uV - 900000, 50000); | 44 | val = DIV_ROUND_UP(min_uV - 900000, 50000); |
45 | else /* Steps of 100mV from 1700mV */ | ||
46 | val = DIV_ROUND_UP(min_uV - 1700000, 100000) + 15; | ||
45 | 47 | ||
46 | if ((val * 50000) + 900000 > max_uV) | 48 | volt = wm8400_ldo_list_voltage(dev, val); |
47 | return -EINVAL; | 49 | if (volt < min_uV || volt > max_uV) |
48 | BUG_ON((val * 50000) + 900000 < min_uV); | 50 | return -EINVAL; |
49 | } else { | ||
50 | /* Steps of 100mV from 1700mV */ | ||
51 | val = DIV_ROUND_UP(min_uV - 1700000, 100000); | ||
52 | |||
53 | if ((val * 100000) + 1700000 > max_uV) | ||
54 | return -EINVAL; | ||
55 | BUG_ON((val * 100000) + 1700000 < min_uV); | ||
56 | |||
57 | val += 0xf; | ||
58 | } | ||
59 | 51 | ||
60 | return val; | 52 | return val; |
61 | } | 53 | } |