diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-05-13 22:35:40 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-14 06:00:39 -0400 |
commit | 4093e739f76e1a17b748f9558e3a48a49507885a (patch) | |
tree | 14dd0e4ed81e05d707398301bf63b517edd974da /drivers/regulator/max8925-regulator.c | |
parent | 3c8983b9ac2f8bf9f23effa4f72ce814f8375397 (diff) |
regulator: max8925: Convert to regulator_list_voltage_linear()
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 | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index 529ee4152f11..7dbae399ebcf 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
@@ -38,9 +38,7 @@ struct max8925_regulator_info { | |||
38 | struct i2c_client *i2c; | 38 | struct i2c_client *i2c; |
39 | struct max8925_chip *chip; | 39 | struct max8925_chip *chip; |
40 | 40 | ||
41 | int min_uV; | ||
42 | int max_uV; | 41 | int max_uV; |
43 | int step_uV; | ||
44 | int vol_reg; | 42 | int vol_reg; |
45 | int enable_reg; | 43 | int enable_reg; |
46 | }; | 44 | }; |
@@ -48,18 +46,12 @@ struct max8925_regulator_info { | |||
48 | static inline int check_range(struct max8925_regulator_info *info, | 46 | static inline int check_range(struct max8925_regulator_info *info, |
49 | int min_uV, int max_uV) | 47 | int min_uV, int max_uV) |
50 | { | 48 | { |
51 | if (min_uV < info->min_uV || min_uV > info->max_uV) | 49 | if (min_uV < info->desc.min_uV || min_uV > info->max_uV) |
52 | return -EINVAL; | 50 | return -EINVAL; |
53 | 51 | ||
54 | return 0; | 52 | return 0; |
55 | } | 53 | } |
56 | 54 | ||
57 | static int max8925_list_voltage(struct regulator_dev *rdev, unsigned index) | ||
58 | { | ||
59 | struct max8925_regulator_info *info = rdev_get_drvdata(rdev); | ||
60 | return info->min_uV + index * info->step_uV; | ||
61 | } | ||
62 | |||
63 | static int max8925_set_voltage(struct regulator_dev *rdev, | 55 | static int max8925_set_voltage(struct regulator_dev *rdev, |
64 | int min_uV, int max_uV, unsigned int *selector) | 56 | int min_uV, int max_uV, unsigned int *selector) |
65 | { | 57 | { |
@@ -71,7 +63,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev, | |||
71 | min_uV, max_uV); | 63 | min_uV, max_uV); |
72 | return -EINVAL; | 64 | return -EINVAL; |
73 | } | 65 | } |
74 | data = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV); | 66 | data = DIV_ROUND_UP(min_uV - info->desc.min_uV, info->desc.uV_step); |
75 | *selector = data; | 67 | *selector = data; |
76 | mask = rdev->desc->n_voltages - 1; | 68 | mask = rdev->desc->n_voltages - 1; |
77 | 69 | ||
@@ -160,7 +152,7 @@ static int max8925_set_dvm_disable(struct regulator_dev *rdev) | |||
160 | } | 152 | } |
161 | 153 | ||
162 | static struct regulator_ops max8925_regulator_sdv_ops = { | 154 | static struct regulator_ops max8925_regulator_sdv_ops = { |
163 | .list_voltage = max8925_list_voltage, | 155 | .list_voltage = regulator_list_voltage_linear, |
164 | .set_voltage = max8925_set_voltage, | 156 | .set_voltage = max8925_set_voltage, |
165 | .get_voltage_sel = max8925_get_voltage_sel, | 157 | .get_voltage_sel = max8925_get_voltage_sel, |
166 | .enable = max8925_enable, | 158 | .enable = max8925_enable, |
@@ -172,7 +164,7 @@ static struct regulator_ops max8925_regulator_sdv_ops = { | |||
172 | }; | 164 | }; |
173 | 165 | ||
174 | static struct regulator_ops max8925_regulator_ldo_ops = { | 166 | static struct regulator_ops max8925_regulator_ldo_ops = { |
175 | .list_voltage = max8925_list_voltage, | 167 | .list_voltage = regulator_list_voltage_linear, |
176 | .set_voltage = max8925_set_voltage, | 168 | .set_voltage = max8925_set_voltage, |
177 | .get_voltage_sel = max8925_get_voltage_sel, | 169 | .get_voltage_sel = max8925_get_voltage_sel, |
178 | .enable = max8925_enable, | 170 | .enable = max8925_enable, |
@@ -189,10 +181,10 @@ static struct regulator_ops max8925_regulator_ldo_ops = { | |||
189 | .id = MAX8925_ID_SD##_id, \ | 181 | .id = MAX8925_ID_SD##_id, \ |
190 | .owner = THIS_MODULE, \ | 182 | .owner = THIS_MODULE, \ |
191 | .n_voltages = 64, \ | 183 | .n_voltages = 64, \ |
184 | .min_uV = min * 1000, \ | ||
185 | .uV_step = step * 1000, \ | ||
192 | }, \ | 186 | }, \ |
193 | .min_uV = min * 1000, \ | ||
194 | .max_uV = max * 1000, \ | 187 | .max_uV = max * 1000, \ |
195 | .step_uV = step * 1000, \ | ||
196 | .vol_reg = MAX8925_SDV##_id, \ | 188 | .vol_reg = MAX8925_SDV##_id, \ |
197 | .enable_reg = MAX8925_SDCTL##_id, \ | 189 | .enable_reg = MAX8925_SDCTL##_id, \ |
198 | } | 190 | } |
@@ -206,10 +198,10 @@ static struct regulator_ops max8925_regulator_ldo_ops = { | |||
206 | .id = MAX8925_ID_LDO##_id, \ | 198 | .id = MAX8925_ID_LDO##_id, \ |
207 | .owner = THIS_MODULE, \ | 199 | .owner = THIS_MODULE, \ |
208 | .n_voltages = 64, \ | 200 | .n_voltages = 64, \ |
201 | .min_uV = min * 1000, \ | ||
202 | .uV_step = step * 1000, \ | ||
209 | }, \ | 203 | }, \ |
210 | .min_uV = min * 1000, \ | ||
211 | .max_uV = max * 1000, \ | 204 | .max_uV = max * 1000, \ |
212 | .step_uV = step * 1000, \ | ||
213 | .vol_reg = MAX8925_LDOVOUT##_id, \ | 205 | .vol_reg = MAX8925_LDOVOUT##_id, \ |
214 | .enable_reg = MAX8925_LDOCTL##_id, \ | 206 | .enable_reg = MAX8925_LDOCTL##_id, \ |
215 | } | 207 | } |
@@ -320,4 +312,3 @@ MODULE_LICENSE("GPL"); | |||
320 | MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); | 312 | MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>"); |
321 | MODULE_DESCRIPTION("Regulator Driver for Maxim 8925 PMIC"); | 313 | MODULE_DESCRIPTION("Regulator Driver for Maxim 8925 PMIC"); |
322 | MODULE_ALIAS("platform:max8925-regulator"); | 314 | MODULE_ALIAS("platform:max8925-regulator"); |
323 | |||