From: Amit Daniel Kachhap <amit.daniel@samsung.com>
To: linux-kernel@vger.kernel.org
Cc: Sangbeom Kim <sbkim73@samsung.com>, Liam Girdwood <lrg@ti.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
amit.kachhap@gmail.com,
Thomas Abraham <thomas.abraham@linaro.org>,
kgene.kim@samsung.com, linux-samsung-soc@vger.kernel.org
Subject: [PATCH 1/4] regulator: s5m8767: Fix to work when platform registers less regulators
Date: Mon, 10 Dec 2012 18:19:39 +0530 [thread overview]
Message-ID: <1355143782-15133-2-git-send-email-amit.daniel@samsung.com> (raw)
In-Reply-To: <1355143782-15133-1-git-send-email-amit.daniel@samsung.com>
Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
---
drivers/regulator/s5m8767.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 2b822be..df0b094 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -168,7 +168,7 @@ static unsigned int s5m8767_opmode_reg[][4] = {
static int s5m8767_get_register(struct regulator_dev *rdev, int *reg,
int *enable_ctrl)
{
- int reg_id = rdev_get_id(rdev);
+ int i, reg_id = rdev_get_id(rdev);
unsigned int mode;
struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev);
@@ -195,8 +195,17 @@ static int s5m8767_get_register(struct regulator_dev *rdev, int *reg,
return -EINVAL;
}
- mode = s5m8767->opmode[reg_id].mode;
- *enable_ctrl = s5m8767_opmode_reg[reg_id][mode] << S5M8767_ENCTRL_SHIFT;
+ for (i = 0; i < s5m8767->num_regulators; i++) {
+ if (s5m8767->opmode[i].id == reg_id) {
+ mode = s5m8767->opmode[i].mode;
+ break;
+ }
+ }
+
+ if (i < s5m8767->num_regulators)
+ *enable_ctrl =
+ s5m8767_opmode_reg[reg_id][mode] << S5M8767_ENCTRL_SHIFT;
+
return 0;
}
@@ -547,7 +556,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
rdev = s5m8767->rdev;
s5m8767->dev = &pdev->dev;
s5m8767->iodev = iodev;
- s5m8767->num_regulators = S5M8767_REG_MAX - 2;
+ s5m8767->num_regulators = pdata->num_regulators;
platform_set_drvdata(pdev, s5m8767);
s5m8767->buck_gpioindex = pdata->buck_default_idx;
--
1.7.1
next prev parent reply other threads:[~2012-12-10 12:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-10 12:49 [PATCH 0/4] regulator: s5m8767: Small fixes and device support Amit Daniel Kachhap
2012-12-10 12:49 ` Amit Daniel Kachhap [this message]
2012-12-11 3:44 ` [PATCH 1/4] regulator: s5m8767: Fix to work when platform registers less regulators Mark Brown
2012-12-10 12:49 ` [PATCH 2/4] regulator: s5m8767: Fix to read the first DVS register Amit Daniel Kachhap
2012-12-11 3:47 ` Mark Brown
2012-12-10 12:49 ` [PATCH 3/4] regulator: s5m8767: Fix to work even if no DVS gpio present Amit Daniel Kachhap
2012-12-11 3:48 ` Mark Brown
2012-12-10 12:49 ` [PATCH 4/4] regulator: add device tree support for s5m8767 Amit Daniel Kachhap
2013-01-08 22:07 ` Thomas Abraham
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=1355143782-15133-2-git-send-email-amit.daniel@samsung.com \
--to=amit.daniel@samsung.com \
--cc=amit.kachhap@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=kgene.kim@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=lrg@ti.com \
--cc=sbkim73@samsung.com \
--cc=thomas.abraham@linaro.org \
/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
all inboxes | Powered by JetHome®