aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8998.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-06-16 21:33:07 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-23 07:16:42 -0400
commit9a0fbb627cfa86303b8eb57377f536c64812cc85 (patch)
treef93b58e260cae057d675f03bb583201567a0086a /drivers/regulator/max8998.c
parentb5152415225ba0d489939778f3b85217b25036db (diff)
regulator: max8998: 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/max8998.c')
-rw-r--r--drivers/regulator/max8998.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 18bb58b9b96e..105dafca3369 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -111,27 +111,6 @@ static const struct voltage_map_desc *ldo_voltage_map[] = {
111 &buck4_voltage_map_desc, /* BUCK4 */ 111 &buck4_voltage_map_desc, /* BUCK4 */
112}; 112};
113 113
114static int max8998_list_voltage(struct regulator_dev *rdev,
115 unsigned int selector)
116{
117 const struct voltage_map_desc *desc;
118 int ldo = rdev_get_id(rdev);
119 int val;
120
121 if (ldo >= ARRAY_SIZE(ldo_voltage_map))
122 return -EINVAL;
123
124 desc = ldo_voltage_map[ldo];
125 if (desc == NULL)
126 return -EINVAL;
127
128 val = desc->min + desc->step * selector;
129 if (val > desc->max)
130 return -EINVAL;
131
132 return val * 1000;
133}
134
135static int max8998_get_enable_register(struct regulator_dev *rdev, 114static int max8998_get_enable_register(struct regulator_dev *rdev,
136 int *reg, int *shift) 115 int *reg, int *shift)
137{ 116{
@@ -392,8 +371,8 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev,
392 /* if previous_voltage equal new voltage, return */ 371 /* if previous_voltage equal new voltage, return */
393 if (previous_sel == i) { 372 if (previous_sel == i) {
394 dev_dbg(max8998->dev, "No voltage change, old:%d, new:%d\n", 373 dev_dbg(max8998->dev, "No voltage change, old:%d, new:%d\n",
395 max8998_list_voltage(rdev, previous_sel), 374 regulator_list_voltage_linear(rdev, previous_sel),
396 max8998_list_voltage(rdev, i)); 375 regulator_list_voltage_linear(rdev, i));
397 return ret; 376 return ret;
398 } 377 }
399 378
@@ -519,7 +498,7 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev,
519} 498}
520 499
521static struct regulator_ops max8998_ldo_ops = { 500static struct regulator_ops max8998_ldo_ops = {
522 .list_voltage = max8998_list_voltage, 501 .list_voltage = regulator_list_voltage_linear,
523 .is_enabled = max8998_ldo_is_enabled, 502 .is_enabled = max8998_ldo_is_enabled,
524 .enable = max8998_ldo_enable, 503 .enable = max8998_ldo_enable,
525 .disable = max8998_ldo_disable, 504 .disable = max8998_ldo_disable,
@@ -530,7 +509,7 @@ static struct regulator_ops max8998_ldo_ops = {
530}; 509};
531 510
532static struct regulator_ops max8998_buck_ops = { 511static struct regulator_ops max8998_buck_ops = {
533 .list_voltage = max8998_list_voltage, 512 .list_voltage = regulator_list_voltage_linear,
534 .is_enabled = max8998_ldo_is_enabled, 513 .is_enabled = max8998_ldo_is_enabled,
535 .enable = max8998_ldo_enable, 514 .enable = max8998_ldo_enable,
536 .disable = max8998_ldo_disable, 515 .disable = max8998_ldo_disable,
@@ -860,7 +839,10 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
860 desc = ldo_voltage_map[id]; 839 desc = ldo_voltage_map[id];
861 if (desc && regulators[index].ops != &max8998_others_ops) { 840 if (desc && regulators[index].ops != &max8998_others_ops) {
862 int count = (desc->max - desc->min) / desc->step + 1; 841 int count = (desc->max - desc->min) / desc->step + 1;
842
863 regulators[index].n_voltages = count; 843 regulators[index].n_voltages = count;
844 regulators[index].min_uV = desc->min * 1000;
845 regulators[index].uV_step = desc->step * 1000;
864 } 846 }
865 847
866 config.dev = max8998->dev; 848 config.dev = max8998->dev;