From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Sangbeom Kim <sbkim73@samsung.com>, Liam Girdwood <lrg@ti.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH] regulator: Make s5m8767_get_voltage_register always return correct register
Date: Sat, 10 Mar 2012 10:59:43 +0800 [thread overview]
Message-ID: <1331348383.3654.1.camel@phoenix> (raw)
Check s5m8767->buck[2|3|4]_gpiodvs status in s5m8767_get_voltage_register
and return correct register accordingly.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/s5m8767.c | 27 +++++++++------------------
1 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 611d02d..58447db 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -219,6 +219,7 @@ static int s5m8767_reg_disable(struct regulator_dev *rdev)
static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg)
{
+ struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
int reg_id = rdev_get_id(rdev);
int reg;
@@ -234,12 +235,18 @@ static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg)
break;
case S5M8767_BUCK2:
reg = S5M8767_REG_BUCK2DVS1;
+ if (s5m8767->buck2_gpiodvs)
+ reg += s5m8767->buck_gpioindex;
break;
case S5M8767_BUCK3:
reg = S5M8767_REG_BUCK3DVS1;
+ if (s5m8767->buck3_gpiodvs)
+ reg += s5m8767->buck_gpioindex;
break;
case S5M8767_BUCK4:
reg = S5M8767_REG_BUCK4DVS1;
+ if (s5m8767->buck4_gpiodvs)
+ reg += s5m8767->buck_gpioindex;
break;
case S5M8767_BUCK5:
reg = S5M8767_REG_BUCK5CTRL2;
@@ -259,7 +266,7 @@ static int s5m8767_get_voltage_register(struct regulator_dev *rdev, int *_reg)
static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
{
struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
- int reg, mask = 0xff, ret;
+ int reg, mask, ret;
int reg_id = rdev_get_id(rdev);
u8 val;
@@ -267,23 +274,7 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
if (ret)
return ret;
- switch (reg_id) {
- case S5M8767_LDO1 ... S5M8767_LDO28:
- mask = 0x3f;
- break;
- case S5M8767_BUCK2:
- if (s5m8767->buck2_gpiodvs)
- reg += s5m8767->buck_gpioindex;
- break;
- case S5M8767_BUCK3:
- if (s5m8767->buck3_gpiodvs)
- reg += s5m8767->buck_gpioindex;
- break;
- case S5M8767_BUCK4:
- if (s5m8767->buck4_gpiodvs)
- reg += s5m8767->buck_gpioindex;
- break;
- }
+ mask = (reg_id < S5M8767_BUCK1) ? 0x3f : 0xff;
ret = s5m_reg_read(s5m8767->iodev, reg, &val);
if (ret)
--
1.7.5.4
next reply other threads:[~2012-03-10 2:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-10 2:59 Axel Lin [this message]
2012-03-14 8:49 ` [PATCH] regulator: Make s5m8767_get_voltage_register always return correct register Sangbeom Kim
2012-03-14 14:11 ` 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=1331348383.3654.1.camel@phoenix \
--to=axel.lin@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
--cc=sbkim73@samsung.com \
/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