From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Margarita Olaya Cabrera <magi@slimlogic.co.uk>,
Liam Girdwood <lrg@ti.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 2/2] regulator: Simplify implementation of tps65912_get_voltage_dcdc
Date: Wed, 14 Mar 2012 10:20:01 +0800 [thread overview]
Message-ID: <1331691601.3782.3.camel@phoenix> (raw)
In-Reply-To: <1331691525.3782.2.camel@phoenix>
Call tps65912_get_sel_register instead of duplicating the same code.
Signed-off-by: Axel Lin <axel.lin@gmail.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
next prev parent reply other threads:[~2012-03-14 2:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-14 2:18 [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx Axel Lin
2012-03-14 2:20 ` Axel Lin [this message]
2012-03-14 12:39 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331691601.3782.3.camel@phoenix \
--to=axel.lin@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
--cc=magi@slimlogic.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox