diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-05-14 22:24:56 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-15 13:32:57 -0400 |
commit | bae5e9c33f44633b71d69b350884b243874fd92d (patch) | |
tree | cb85c8a1c0ca4c6e9c50ee7c86543b5f5f1474d8 /drivers/regulator/da903x.c | |
parent | c972a029483ac5a546a6405e30e4eede6fbd19f9 (diff) |
regulator: da903x: Kill da903x_[get|set]_[ldo12|ldo14]_voltage_sel() functions
Now the implementation of da903x_set_voltage_sel, da9030_set_ldo14_voltage_sel,
and da9034_set_ldo12_voltage_sel are exactly the same.
da903x_get_voltage_sel, da9030_get_ldo14_voltage_sel and
da9034_get_ldo12_voltage_sel are exactly the same.
So we can use da903x_[get|set]_voltage_sel and kill other functions.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/da903x.c')
-rw-r--r-- | drivers/regulator/da903x.c | 73 |
1 files changed, 6 insertions, 67 deletions
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index 6e78ef1667fb..1005f5f7e603 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c | |||
@@ -101,8 +101,7 @@ static inline int check_range(struct da903x_regulator_info *info, | |||
101 | } | 101 | } |
102 | 102 | ||
103 | /* DA9030/DA9034 common operations */ | 103 | /* DA9030/DA9034 common operations */ |
104 | static int da903x_set_ldo_voltage_sel(struct regulator_dev *rdev, | 104 | static int da903x_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) |
105 | unsigned selector) | ||
106 | { | 105 | { |
107 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | 106 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); |
108 | struct device *da9034_dev = to_da903x_dev(rdev); | 107 | struct device *da9034_dev = to_da903x_dev(rdev); |
@@ -185,19 +184,6 @@ static int da9030_set_ldo1_15_voltage_sel(struct regulator_dev *rdev, | |||
185 | return da903x_update(da903x_dev, info->vol_reg, val, mask); | 184 | return da903x_update(da903x_dev, info->vol_reg, val, mask); |
186 | } | 185 | } |
187 | 186 | ||
188 | static int da9030_set_ldo14_voltage_sel(struct regulator_dev *rdev, | ||
189 | unsigned selector) | ||
190 | { | ||
191 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | ||
192 | struct device *da903x_dev = to_da903x_dev(rdev); | ||
193 | uint8_t val, mask; | ||
194 | |||
195 | val = selector << info->vol_shift; | ||
196 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | ||
197 | |||
198 | return da903x_update(da903x_dev, info->vol_reg, val, mask); | ||
199 | } | ||
200 | |||
201 | static int da9030_map_ldo14_voltage(struct regulator_dev *rdev, | 187 | static int da9030_map_ldo14_voltage(struct regulator_dev *rdev, |
202 | int min_uV, int max_uV) | 188 | int min_uV, int max_uV) |
203 | { | 189 | { |
@@ -220,23 +206,6 @@ static int da9030_map_ldo14_voltage(struct regulator_dev *rdev, | |||
220 | return sel; | 206 | return sel; |
221 | } | 207 | } |
222 | 208 | ||
223 | static int da9030_get_ldo14_voltage_sel(struct regulator_dev *rdev) | ||
224 | { | ||
225 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | ||
226 | struct device *da903x_dev = to_da903x_dev(rdev); | ||
227 | uint8_t val, mask; | ||
228 | int ret; | ||
229 | |||
230 | ret = da903x_read(da903x_dev, info->vol_reg, &val); | ||
231 | if (ret) | ||
232 | return ret; | ||
233 | |||
234 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | ||
235 | val = (val & mask) >> info->vol_shift; | ||
236 | |||
237 | return val; | ||
238 | } | ||
239 | |||
240 | static int da9030_list_ldo14_voltage(struct regulator_dev *rdev, | 209 | static int da9030_list_ldo14_voltage(struct regulator_dev *rdev, |
241 | unsigned selector) | 210 | unsigned selector) |
242 | { | 211 | { |
@@ -277,19 +246,6 @@ static int da9034_set_dvc_voltage_sel(struct regulator_dev *rdev, | |||
277 | return ret; | 246 | return ret; |
278 | } | 247 | } |
279 | 248 | ||
280 | static int da9034_set_ldo12_voltage_sel(struct regulator_dev *rdev, | ||
281 | unsigned selector) | ||
282 | { | ||
283 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | ||
284 | struct device *da9034_dev = to_da903x_dev(rdev); | ||
285 | uint8_t val, mask; | ||
286 | |||
287 | val = selector << info->vol_shift; | ||
288 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | ||
289 | |||
290 | return da903x_update(da9034_dev, info->vol_reg, val, mask); | ||
291 | } | ||
292 | |||
293 | static int da9034_map_ldo12_voltage(struct regulator_dev *rdev, | 249 | static int da9034_map_ldo12_voltage(struct regulator_dev *rdev, |
294 | int min_uV, int max_uV) | 250 | int min_uV, int max_uV) |
295 | { | 251 | { |
@@ -307,23 +263,6 @@ static int da9034_map_ldo12_voltage(struct regulator_dev *rdev, | |||
307 | return sel; | 263 | return sel; |
308 | } | 264 | } |
309 | 265 | ||
310 | static int da9034_get_ldo12_voltage_sel(struct regulator_dev *rdev) | ||
311 | { | ||
312 | struct da903x_regulator_info *info = rdev_get_drvdata(rdev); | ||
313 | struct device *da9034_dev = to_da903x_dev(rdev); | ||
314 | uint8_t val, mask; | ||
315 | int ret; | ||
316 | |||
317 | ret = da903x_read(da9034_dev, info->vol_reg, &val); | ||
318 | if (ret) | ||
319 | return ret; | ||
320 | |||
321 | mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; | ||
322 | val = (val & mask) >> info->vol_shift; | ||
323 | |||
324 | return val; | ||
325 | } | ||
326 | |||
327 | static int da9034_list_ldo12_voltage(struct regulator_dev *rdev, | 266 | static int da9034_list_ldo12_voltage(struct regulator_dev *rdev, |
328 | unsigned selector) | 267 | unsigned selector) |
329 | { | 268 | { |
@@ -342,7 +281,7 @@ static int da9034_list_ldo12_voltage(struct regulator_dev *rdev, | |||
342 | } | 281 | } |
343 | 282 | ||
344 | static struct regulator_ops da903x_regulator_ldo_ops = { | 283 | static struct regulator_ops da903x_regulator_ldo_ops = { |
345 | .set_voltage_sel = da903x_set_ldo_voltage_sel, | 284 | .set_voltage_sel = da903x_set_voltage_sel, |
346 | .get_voltage_sel = da903x_get_voltage_sel, | 285 | .get_voltage_sel = da903x_get_voltage_sel, |
347 | .list_voltage = regulator_list_voltage_linear, | 286 | .list_voltage = regulator_list_voltage_linear, |
348 | .map_voltage = regulator_map_voltage_linear, | 287 | .map_voltage = regulator_map_voltage_linear, |
@@ -353,8 +292,8 @@ static struct regulator_ops da903x_regulator_ldo_ops = { | |||
353 | 292 | ||
354 | /* NOTE: this is dedicated for the insane DA9030 LDO14 */ | 293 | /* NOTE: this is dedicated for the insane DA9030 LDO14 */ |
355 | static struct regulator_ops da9030_regulator_ldo14_ops = { | 294 | static struct regulator_ops da9030_regulator_ldo14_ops = { |
356 | .set_voltage_sel = da9030_set_ldo14_voltage_sel, | 295 | .set_voltage_sel = da903x_set_voltage_sel, |
357 | .get_voltage_sel = da9030_get_ldo14_voltage_sel, | 296 | .get_voltage_sel = da903x_get_voltage_sel, |
358 | .list_voltage = da9030_list_ldo14_voltage, | 297 | .list_voltage = da9030_list_ldo14_voltage, |
359 | .map_voltage = da9030_map_ldo14_voltage, | 298 | .map_voltage = da9030_map_ldo14_voltage, |
360 | .enable = da903x_enable, | 299 | .enable = da903x_enable, |
@@ -385,8 +324,8 @@ static struct regulator_ops da9034_regulator_dvc_ops = { | |||
385 | 324 | ||
386 | /* NOTE: this is dedicated for the insane LDO12 */ | 325 | /* NOTE: this is dedicated for the insane LDO12 */ |
387 | static struct regulator_ops da9034_regulator_ldo12_ops = { | 326 | static struct regulator_ops da9034_regulator_ldo12_ops = { |
388 | .set_voltage_sel = da9034_set_ldo12_voltage_sel, | 327 | .set_voltage_sel = da903x_set_voltage_sel, |
389 | .get_voltage_sel = da9034_get_ldo12_voltage_sel, | 328 | .get_voltage_sel = da903x_get_voltage_sel, |
390 | .list_voltage = da9034_list_ldo12_voltage, | 329 | .list_voltage = da9034_list_ldo12_voltage, |
391 | .map_voltage = da9034_map_ldo12_voltage, | 330 | .map_voltage = da9034_map_ldo12_voltage, |
392 | .enable = da903x_enable, | 331 | .enable = da903x_enable, |