diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-01 21:16:08 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-02 18:15:19 -0400 |
commit | 7f52ba7791a35a8e13a3be992fc98da66e68b77d (patch) | |
tree | 601b53f79ef9515e6cfae40eff5d9ae59ed74267 /drivers/regulator/max8925-regulator.c | |
parent | 42ff943148f78d6d60d345a52c7cfc6ae3bdf1cf (diff) |
regulator: Add missing n_voltages setting for max8925
The n_voltages are the same for all regulators: (max - min / step) + 1 == 64.
The vol_shift is always 0, and the vol_nbits is always the same as n_voltages
setting. Thus we can remove vol_shitf and vol_nbits fields from struct
max8925_regulator_info.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8925-regulator.c')
-rw-r--r-- | drivers/regulator/max8925-regulator.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index ad8b093861d4..a62f3b5cc312 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
@@ -42,8 +42,6 @@ struct max8925_regulator_info { | |||
42 | int max_uV; | 42 | int max_uV; |
43 | int step_uV; | 43 | int step_uV; |
44 | int vol_reg; | 44 | int vol_reg; |
45 | int vol_shift; | ||
46 | int vol_nbits; | ||
47 | int enable_reg; | 45 | int enable_reg; |
48 | }; | 46 | }; |
49 | 47 | ||
@@ -75,8 +73,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev, | |||
75 | } | 73 | } |
76 | data = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV); | 74 | data = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV); |
77 | *selector = data; | 75 | *selector = data; |
78 | data <<= info->vol_shift; | 76 | mask = rdev->desc->n_voltages - 1; |
79 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | ||
80 | 77 | ||
81 | return max8925_set_bits(info->i2c, info->vol_reg, mask, data); | 78 | return max8925_set_bits(info->i2c, info->vol_reg, mask, data); |
82 | } | 79 | } |
@@ -90,8 +87,8 @@ static int max8925_get_voltage(struct regulator_dev *rdev) | |||
90 | ret = max8925_reg_read(info->i2c, info->vol_reg); | 87 | ret = max8925_reg_read(info->i2c, info->vol_reg); |
91 | if (ret < 0) | 88 | if (ret < 0) |
92 | return ret; | 89 | return ret; |
93 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | 90 | mask = rdev->desc->n_voltages - 1; |
94 | data = (ret & mask) >> info->vol_shift; | 91 | data = ret & mask; |
95 | 92 | ||
96 | return max8925_list_voltage(rdev, data); | 93 | return max8925_list_voltage(rdev, data); |
97 | } | 94 | } |
@@ -191,13 +188,12 @@ static struct regulator_ops max8925_regulator_ldo_ops = { | |||
191 | .type = REGULATOR_VOLTAGE, \ | 188 | .type = REGULATOR_VOLTAGE, \ |
192 | .id = MAX8925_ID_SD##_id, \ | 189 | .id = MAX8925_ID_SD##_id, \ |
193 | .owner = THIS_MODULE, \ | 190 | .owner = THIS_MODULE, \ |
191 | .n_voltages = 64, \ | ||
194 | }, \ | 192 | }, \ |
195 | .min_uV = min * 1000, \ | 193 | .min_uV = min * 1000, \ |
196 | .max_uV = max * 1000, \ | 194 | .max_uV = max * 1000, \ |
197 | .step_uV = step * 1000, \ | 195 | .step_uV = step * 1000, \ |
198 | .vol_reg = MAX8925_SDV##_id, \ | 196 | .vol_reg = MAX8925_SDV##_id, \ |
199 | .vol_shift = 0, \ | ||
200 | .vol_nbits = 6, \ | ||
201 | .enable_reg = MAX8925_SDCTL##_id, \ | 197 | .enable_reg = MAX8925_SDCTL##_id, \ |
202 | } | 198 | } |
203 | 199 | ||
@@ -209,13 +205,12 @@ static struct regulator_ops max8925_regulator_ldo_ops = { | |||
209 | .type = REGULATOR_VOLTAGE, \ | 205 | .type = REGULATOR_VOLTAGE, \ |
210 | .id = MAX8925_ID_LDO##_id, \ | 206 | .id = MAX8925_ID_LDO##_id, \ |
211 | .owner = THIS_MODULE, \ | 207 | .owner = THIS_MODULE, \ |
208 | .n_voltages = 64, \ | ||
212 | }, \ | 209 | }, \ |
213 | .min_uV = min * 1000, \ | 210 | .min_uV = min * 1000, \ |
214 | .max_uV = max * 1000, \ | 211 | .max_uV = max * 1000, \ |
215 | .step_uV = step * 1000, \ | 212 | .step_uV = step * 1000, \ |
216 | .vol_reg = MAX8925_LDOVOUT##_id, \ | 213 | .vol_reg = MAX8925_LDOVOUT##_id, \ |
217 | .vol_shift = 0, \ | ||
218 | .vol_nbits = 6, \ | ||
219 | .enable_reg = MAX8925_LDOCTL##_id, \ | 214 | .enable_reg = MAX8925_LDOCTL##_id, \ |
220 | } | 215 | } |
221 | 216 | ||