diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-06 08:01:38 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-07 19:36:38 -0400 |
commit | fedd89b1aafd6b2bf7c0b4009fd616a02484ae80 (patch) | |
tree | 50e89e70e885d2a42a5aa2c463ce0515b35db7f8 /drivers/regulator/palmas-regulator.c | |
parent | 999f0c7cb8e7c378bd1f3fcd56cf8dc5a30c83e4 (diff) |
regulator: palmas: Slightly code change for better readability
It's a little bit hard to read that the "else" case means id == PALMAS_REG_SMPS10.
if (id != PALMAS_REG_SMPS10){
do something for the cases id != PALMAS_REG_SMPS10;
} else {
do something for the case id == PALMAS_REG_SMPS10;
}
This patch changes above syntax to switch statement.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/palmas-regulator.c')
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 1a0924d81b2a..55267bbfcd9c 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -516,7 +516,15 @@ static int palmas_smps_init(struct palmas *palmas, int id, | |||
516 | if (ret) | 516 | if (ret) |
517 | return ret; | 517 | return ret; |
518 | 518 | ||
519 | if (id != PALMAS_REG_SMPS10) { | 519 | switch (id) { |
520 | case PALMAS_REG_SMPS10: | ||
521 | if (reg_init->mode_sleep) { | ||
522 | reg &= ~PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK; | ||
523 | reg |= reg_init->mode_sleep << | ||
524 | PALMAS_SMPS10_CTRL_MODE_SLEEP_SHIFT; | ||
525 | } | ||
526 | break; | ||
527 | default: | ||
520 | if (reg_init->warm_reset) | 528 | if (reg_init->warm_reset) |
521 | reg |= PALMAS_SMPS12_CTRL_WR_S; | 529 | reg |= PALMAS_SMPS12_CTRL_WR_S; |
522 | 530 | ||
@@ -528,14 +536,8 @@ static int palmas_smps_init(struct palmas *palmas, int id, | |||
528 | reg |= reg_init->mode_sleep << | 536 | reg |= reg_init->mode_sleep << |
529 | PALMAS_SMPS12_CTRL_MODE_SLEEP_SHIFT; | 537 | PALMAS_SMPS12_CTRL_MODE_SLEEP_SHIFT; |
530 | } | 538 | } |
531 | } else { | ||
532 | if (reg_init->mode_sleep) { | ||
533 | reg &= ~PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK; | ||
534 | reg |= reg_init->mode_sleep << | ||
535 | PALMAS_SMPS10_CTRL_MODE_SLEEP_SHIFT; | ||
536 | } | ||
537 | |||
538 | } | 539 | } |
540 | |||
539 | ret = palmas_smps_write(palmas, addr, reg); | 541 | ret = palmas_smps_write(palmas, addr, reg); |
540 | if (ret) | 542 | if (ret) |
541 | return ret; | 543 | return ret; |
@@ -659,10 +661,8 @@ static __devinit int palmas_probe(struct platform_device *pdev) | |||
659 | pmic->desc[id].name = palmas_regs_info[id].name; | 661 | pmic->desc[id].name = palmas_regs_info[id].name; |
660 | pmic->desc[id].id = id; | 662 | pmic->desc[id].id = id; |
661 | 663 | ||
662 | if (id != PALMAS_REG_SMPS10) { | 664 | switch (id) { |
663 | pmic->desc[id].ops = &palmas_ops_smps; | 665 | case PALMAS_REG_SMPS10: |
664 | pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; | ||
665 | } else { | ||
666 | pmic->desc[id].n_voltages = PALMAS_SMPS10_NUM_VOLTAGES; | 666 | pmic->desc[id].n_voltages = PALMAS_SMPS10_NUM_VOLTAGES; |
667 | pmic->desc[id].ops = &palmas_ops_smps10; | 667 | pmic->desc[id].ops = &palmas_ops_smps10; |
668 | pmic->desc[id].vsel_reg = PALMAS_SMPS10_CTRL; | 668 | pmic->desc[id].vsel_reg = PALMAS_SMPS10_CTRL; |
@@ -671,6 +671,10 @@ static __devinit int palmas_probe(struct platform_device *pdev) | |||
671 | pmic->desc[id].enable_mask = SMPS10_BOOST_EN; | 671 | pmic->desc[id].enable_mask = SMPS10_BOOST_EN; |
672 | pmic->desc[id].min_uV = 3750000; | 672 | pmic->desc[id].min_uV = 3750000; |
673 | pmic->desc[id].uV_step = 1250000; | 673 | pmic->desc[id].uV_step = 1250000; |
674 | break; | ||
675 | default: | ||
676 | pmic->desc[id].ops = &palmas_ops_smps; | ||
677 | pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; | ||
674 | } | 678 | } |
675 | 679 | ||
676 | pmic->desc[id].type = REGULATOR_VOLTAGE; | 680 | pmic->desc[id].type = REGULATOR_VOLTAGE; |