diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-18 02:25:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-26 06:50:33 -0400 |
commit | e2eb169b1bc207dd1a79109d85b098b241be2e9b (patch) | |
tree | 6740f455fc512e8588fa8d78e12803a1ac0f0040 | |
parent | 7f217d36dce7e3e2789cfbd91ae53a36a98df837 (diff) |
regulator: s5m8767: Convert to regulator_list_voltage_linear
In current code, .list_voltage and .set_voltage_sel callbacks for BUCK7 and
BUCK8 return -EINVAL.
This patch adds s5m8767_buck78_ops for BUCK7 and BUCK8 which does not set
.list_voltage, .get_voltage_sel and .set_voltage_sel. ( This has the same
effect of returning -EINVAL in the callbacks)
Then for all the users of s5m8767_list_voltage, we don't need to worry about
the case reg_voltage_map[reg_id] is NULL.
So we can convert s5m8767_list_voltage to regulator_list_voltage_linear.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | drivers/regulator/s5m8767.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 533bde68e4b7..1ad9c3c0da8d 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -121,27 +121,6 @@ static const struct s5m_voltage_desc *reg_voltage_map[] = { | |||
121 | [S5M8767_BUCK9] = &buck_voltage_val3, | 121 | [S5M8767_BUCK9] = &buck_voltage_val3, |
122 | }; | 122 | }; |
123 | 123 | ||
124 | static int s5m8767_list_voltage(struct regulator_dev *rdev, | ||
125 | unsigned int selector) | ||
126 | { | ||
127 | const struct s5m_voltage_desc *desc; | ||
128 | int reg_id = rdev_get_id(rdev); | ||
129 | int val; | ||
130 | |||
131 | if (reg_id >= ARRAY_SIZE(reg_voltage_map) || reg_id < 0) | ||
132 | return -EINVAL; | ||
133 | |||
134 | desc = reg_voltage_map[reg_id]; | ||
135 | if (desc == NULL) | ||
136 | return -EINVAL; | ||
137 | |||
138 | val = desc->min + desc->step * selector; | ||
139 | if (val > desc->max) | ||
140 | return -EINVAL; | ||
141 | |||
142 | return val; | ||
143 | } | ||
144 | |||
145 | static unsigned int s5m8767_opmode_reg[][4] = { | 124 | static unsigned int s5m8767_opmode_reg[][4] = { |
146 | /* {OFF, ON, LOWPOWER, SUSPEND} */ | 125 | /* {OFF, ON, LOWPOWER, SUSPEND} */ |
147 | /* LDO1 ... LDO28 */ | 126 | /* LDO1 ... LDO28 */ |
@@ -449,7 +428,7 @@ static int s5m8767_set_voltage_time_sel(struct regulator_dev *rdev, | |||
449 | } | 428 | } |
450 | 429 | ||
451 | static struct regulator_ops s5m8767_ops = { | 430 | static struct regulator_ops s5m8767_ops = { |
452 | .list_voltage = s5m8767_list_voltage, | 431 | .list_voltage = regulator_list_voltage_linear, |
453 | .is_enabled = s5m8767_reg_is_enabled, | 432 | .is_enabled = s5m8767_reg_is_enabled, |
454 | .enable = s5m8767_reg_enable, | 433 | .enable = s5m8767_reg_enable, |
455 | .disable = s5m8767_reg_disable, | 434 | .disable = s5m8767_reg_disable, |
@@ -458,6 +437,12 @@ static struct regulator_ops s5m8767_ops = { | |||
458 | .set_voltage_time_sel = s5m8767_set_voltage_time_sel, | 437 | .set_voltage_time_sel = s5m8767_set_voltage_time_sel, |
459 | }; | 438 | }; |
460 | 439 | ||
440 | static struct regulator_ops s5m8767_buck78_ops = { | ||
441 | .is_enabled = s5m8767_reg_is_enabled, | ||
442 | .enable = s5m8767_reg_enable, | ||
443 | .disable = s5m8767_reg_disable, | ||
444 | }; | ||
445 | |||
461 | #define s5m8767_regulator_desc(_name) { \ | 446 | #define s5m8767_regulator_desc(_name) { \ |
462 | .name = #_name, \ | 447 | .name = #_name, \ |
463 | .id = S5M8767_##_name, \ | 448 | .id = S5M8767_##_name, \ |
@@ -466,6 +451,14 @@ static struct regulator_ops s5m8767_ops = { | |||
466 | .owner = THIS_MODULE, \ | 451 | .owner = THIS_MODULE, \ |
467 | } | 452 | } |
468 | 453 | ||
454 | #define s5m8767_regulator_buck78_desc(_name) { \ | ||
455 | .name = #_name, \ | ||
456 | .id = S5M8767_##_name, \ | ||
457 | .ops = &s5m8767_buck78_ops, \ | ||
458 | .type = REGULATOR_VOLTAGE, \ | ||
459 | .owner = THIS_MODULE, \ | ||
460 | } | ||
461 | |||
469 | static struct regulator_desc regulators[] = { | 462 | static struct regulator_desc regulators[] = { |
470 | s5m8767_regulator_desc(LDO1), | 463 | s5m8767_regulator_desc(LDO1), |
471 | s5m8767_regulator_desc(LDO2), | 464 | s5m8767_regulator_desc(LDO2), |
@@ -501,8 +494,8 @@ static struct regulator_desc regulators[] = { | |||
501 | s5m8767_regulator_desc(BUCK4), | 494 | s5m8767_regulator_desc(BUCK4), |
502 | s5m8767_regulator_desc(BUCK5), | 495 | s5m8767_regulator_desc(BUCK5), |
503 | s5m8767_regulator_desc(BUCK6), | 496 | s5m8767_regulator_desc(BUCK6), |
504 | s5m8767_regulator_desc(BUCK7), | 497 | s5m8767_regulator_buck78_desc(BUCK7), |
505 | s5m8767_regulator_desc(BUCK8), | 498 | s5m8767_regulator_buck78_desc(BUCK8), |
506 | s5m8767_regulator_desc(BUCK9), | 499 | s5m8767_regulator_desc(BUCK9), |
507 | }; | 500 | }; |
508 | 501 | ||
@@ -751,9 +744,12 @@ static __devinit int s5m8767_pmic_probe(struct platform_device *pdev) | |||
751 | int id = pdata->regulators[i].id; | 744 | int id = pdata->regulators[i].id; |
752 | 745 | ||
753 | desc = reg_voltage_map[id]; | 746 | desc = reg_voltage_map[id]; |
754 | if (desc) | 747 | if (desc) { |
755 | regulators[id].n_voltages = | 748 | regulators[id].n_voltages = |
756 | (desc->max - desc->min) / desc->step + 1; | 749 | (desc->max - desc->min) / desc->step + 1; |
750 | regulators[id].min_uV = desc->min; | ||
751 | regulators[id].uV_step = desc->step; | ||
752 | } | ||
757 | 753 | ||
758 | config.dev = s5m8767->dev; | 754 | config.dev = s5m8767->dev; |
759 | config.init_data = pdata->regulators[i].initdata; | 755 | config.init_data = pdata->regulators[i].initdata; |