summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/tps65912-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-03-14 03:20:01 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-03-14 13:37:23 +0100
commitc567556e75534316f1ae800b0a0fbbc687d0662e (patch)
treea66445c8ea0f9e81e5bc8a7685283eaf8c462f1c /drivers/regulator/tps65912-regulator.c
parentregulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx (diff)
downloadlinux-c567556e75534316f1ae800b0a0fbbc687d0662e.tar.xz
linux-c567556e75534316f1ae800b0a0fbbc687d0662e.zip
regulator: Simplify implementation of tps65912_get_voltage_dcdc
Call tps65912_get_sel_register instead of duplicating the same code. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/tps65912-regulator.c')
-rw-r--r--drivers/regulator/tps65912-regulator.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index 988d0ec40d2e..b36799b1f530 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -409,34 +409,13 @@ static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
struct tps65912_reg *pmic = rdev_get_drvdata(dev);
struct tps65912 *mfd = pmic->mfd;
int id = rdev_get_id(dev);
- int opvsel = 0, avsel = 0, sr, vsel;
+ int reg, vsel;
- switch (id) {
- case TPS65912_REG_DCDC1:
- opvsel = tps65912_reg_read(mfd, TPS65912_DCDC1_OP);
- avsel = tps65912_reg_read(mfd, TPS65912_DCDC1_AVS);
- break;
- case TPS65912_REG_DCDC2:
- opvsel = tps65912_reg_read(mfd, TPS65912_DCDC2_OP);
- avsel = tps65912_reg_read(mfd, TPS65912_DCDC2_AVS);
- break;
- case TPS65912_REG_DCDC3:
- opvsel = tps65912_reg_read(mfd, TPS65912_DCDC3_OP);
- avsel = tps65912_reg_read(mfd, TPS65912_DCDC3_AVS);
- break;
- case TPS65912_REG_DCDC4:
- opvsel = tps65912_reg_read(mfd, TPS65912_DCDC4_OP);
- avsel = tps65912_reg_read(mfd, TPS65912_DCDC4_AVS);
- break;
- default:
- return -EINVAL;
- }
+ reg = tps65912_get_sel_register(pmic, id);
+ if (reg < 0)
+ return reg;
- sr = (opvsel & OP_SELREG_MASK) >> OP_SELREG_SHIFT;
- if (sr)
- vsel = avsel;
- else
- vsel = opvsel;
+ vsel = tps65912_reg_read(mfd, reg);
vsel &= 0x3F;
return tps65912_list_voltage_dcdc(dev, vsel);