diff options
| author | Axel Lin <axel.lin@ingics.com> | 2012-12-28 20:38:50 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-17 02:12:22 -0500 |
| commit | 854f73ecb5c207007f9e850abd6f82ab89eaefb7 (patch) | |
| tree | df6f7660c7e3a50021127fe9e7fff5549d9da86d | |
| parent | 3051019409d99084f3b8f090b75d969adcc882e7 (diff) | |
regulator: s5m8767: Remove max_vol parameter from s5m8767_convert_voltage_to_sel
It looks pointless to pass max_vol to s5m8767_convert_voltage_to_sel().
Compare selected voltage to desc->max is enough to ensure selected voltage
is in supported range.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
| -rw-r--r-- | drivers/regulator/s5m8767.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 33b65c9ad5d5..94b8e484ef90 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
| @@ -323,16 +323,15 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev) | |||
| 323 | return val; | 323 | return val; |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | static int s5m8767_convert_voltage_to_sel( | 326 | static int s5m8767_convert_voltage_to_sel(const struct sec_voltage_desc *desc, |
| 327 | const struct sec_voltage_desc *desc, | 327 | int min_vol) |
| 328 | int min_vol, int max_vol) | ||
| 329 | { | 328 | { |
| 330 | int selector = 0; | 329 | int selector = 0; |
| 331 | 330 | ||
| 332 | if (desc == NULL) | 331 | if (desc == NULL) |
| 333 | return -EINVAL; | 332 | return -EINVAL; |
| 334 | 333 | ||
| 335 | if (max_vol < desc->min || min_vol > desc->max) | 334 | if (min_vol > desc->max) |
| 336 | return -EINVAL; | 335 | return -EINVAL; |
| 337 | 336 | ||
| 338 | if (min_vol < desc->min) | 337 | if (min_vol < desc->min) |
| @@ -340,7 +339,7 @@ static int s5m8767_convert_voltage_to_sel( | |||
| 340 | 339 | ||
| 341 | selector = DIV_ROUND_UP(min_vol - desc->min, desc->step); | 340 | selector = DIV_ROUND_UP(min_vol - desc->min, desc->step); |
| 342 | 341 | ||
| 343 | if (desc->min + desc->step * selector > max_vol) | 342 | if (desc->min + desc->step * selector > desc->max) |
| 344 | return -EINVAL; | 343 | return -EINVAL; |
| 345 | 344 | ||
| 346 | return selector; | 345 | return selector; |
| @@ -577,23 +576,17 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
| 577 | s5m8767->opmode = pdata->opmode; | 576 | s5m8767->opmode = pdata->opmode; |
| 578 | 577 | ||
| 579 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 578 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
| 580 | pdata->buck2_init, | 579 | pdata->buck2_init); |
| 581 | pdata->buck2_init + | ||
| 582 | buck_voltage_val2.step); | ||
| 583 | 580 | ||
| 584 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init); | 581 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init); |
| 585 | 582 | ||
| 586 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 583 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
| 587 | pdata->buck3_init, | 584 | pdata->buck3_init); |
| 588 | pdata->buck3_init + | ||
| 589 | buck_voltage_val2.step); | ||
| 590 | 585 | ||
| 591 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init); | 586 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init); |
| 592 | 587 | ||
| 593 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 588 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
| 594 | pdata->buck4_init, | 589 | pdata->buck4_init); |
| 595 | pdata->buck4_init + | ||
| 596 | buck_voltage_val2.step); | ||
| 597 | 590 | ||
| 598 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init); | 591 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init); |
| 599 | 592 | ||
| @@ -602,27 +595,21 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
| 602 | s5m8767->buck2_vol[i] = | 595 | s5m8767->buck2_vol[i] = |
| 603 | s5m8767_convert_voltage_to_sel( | 596 | s5m8767_convert_voltage_to_sel( |
| 604 | &buck_voltage_val2, | 597 | &buck_voltage_val2, |
| 605 | pdata->buck2_voltage[i], | 598 | pdata->buck2_voltage[i]); |
| 606 | pdata->buck2_voltage[i] + | ||
| 607 | buck_voltage_val2.step); | ||
| 608 | } | 599 | } |
| 609 | 600 | ||
| 610 | if (s5m8767->buck3_gpiodvs) { | 601 | if (s5m8767->buck3_gpiodvs) { |
| 611 | s5m8767->buck3_vol[i] = | 602 | s5m8767->buck3_vol[i] = |
| 612 | s5m8767_convert_voltage_to_sel( | 603 | s5m8767_convert_voltage_to_sel( |
| 613 | &buck_voltage_val2, | 604 | &buck_voltage_val2, |
| 614 | pdata->buck3_voltage[i], | 605 | pdata->buck3_voltage[i]); |
| 615 | pdata->buck3_voltage[i] + | ||
| 616 | buck_voltage_val2.step); | ||
| 617 | } | 606 | } |
| 618 | 607 | ||
| 619 | if (s5m8767->buck4_gpiodvs) { | 608 | if (s5m8767->buck4_gpiodvs) { |
| 620 | s5m8767->buck4_vol[i] = | 609 | s5m8767->buck4_vol[i] = |
| 621 | s5m8767_convert_voltage_to_sel( | 610 | s5m8767_convert_voltage_to_sel( |
| 622 | &buck_voltage_val2, | 611 | &buck_voltage_val2, |
| 623 | pdata->buck4_voltage[i], | 612 | pdata->buck4_voltage[i]); |
| 624 | pdata->buck4_voltage[i] + | ||
| 625 | buck_voltage_val2.step); | ||
| 626 | } | 613 | } |
| 627 | } | 614 | } |
| 628 | 615 | ||
