[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1331691601.3782.3.camel@phoenix>
Date: Wed, 14 Mar 2012 10:20:01 +0800
From: Axel Lin <axel.lin@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Margarita Olaya Cabrera <magi@...mlogic.co.uk>,
Liam Girdwood <lrg@...com>,
Mark Brown <broonie@...nsource.wolfsonmicro.com>
Subject: [PATCH 2/2] 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@...il.com>
---
drivers/regulator/tps65912-regulator.c | 31 +++++--------------------------
1 files changed, 5 insertions(+), 26 deletions(-)
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index 988d0ec..b36799b 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);
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists