All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kim, Milo" <Milo.Kim@ti.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Axel Lin <axel.lin@ingics.com>, "Girdwood, Liam" <lrg@ti.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] regulator-core: update all enable GPIO state in _enable/disable
Date: Thu, 10 Jan 2013 09:46:12 +0000	[thread overview]
Message-ID: <A874F61F95741C4A9BA573A70FE3998F69E122AA@DQHE02.ent.ti.com> (raw)

 When a regulator is enabled or disabled, enable GPIO state is changed if it is
 used.
 If multiple regulators are controlled by one shared GPIO, pin states of other
 GPIOs should be updated also.

 Look up the list of regulators and change the enable pin state if same GPIO
 is used. It guarantees exact value of regulator_is_enabled().

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
---
 drivers/regulator/core.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 21b4247..44b2d61 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1473,6 +1473,17 @@ static int regulator_enable_gpio_request(struct regulator_dev *rdev,
 				rdev_get_name(rdev));
 }
 
+static void update_enable_gpio_state(int gpio, bool enable)
+{
+	struct regulator_dev *r;
+
+	/* Update shared enable pin state */
+	list_for_each_entry(r, &regulator_list, list) {
+		if (r->ena_gpio == gpio)
+			r->ena_gpio_state = enable ? 1 : 0;
+	}
+}
+
 static int _regulator_do_enable(struct regulator_dev *rdev)
 {
 	int ret, delay;
@@ -1491,7 +1502,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
 	if (rdev->ena_gpio) {
 		gpio_set_value_cansleep(rdev->ena_gpio,
 					!rdev->ena_gpio_invert);
-		rdev->ena_gpio_state = 1;
+		update_enable_gpio_state(rdev->ena_gpio, true);
 	} else if (rdev->desc->ops->enable) {
 		ret = rdev->desc->ops->enable(rdev);
 		if (ret < 0)
@@ -1595,8 +1606,7 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
 	if (rdev->ena_gpio) {
 		gpio_set_value_cansleep(rdev->ena_gpio,
 					rdev->ena_gpio_invert);
-		rdev->ena_gpio_state = 0;
-
+		update_enable_gpio_state(rdev->ena_gpio, false);
 	} else if (rdev->desc->ops->disable) {
 		ret = rdev->desc->ops->disable(rdev);
 		if (ret != 0)
-- 
1.7.9.5


Best Regards,
Milo



             reply	other threads:[~2013-01-10  9:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10  9:46 Kim, Milo [this message]
2013-01-13 22:42 ` [PATCH 2/3] regulator-core: update all enable GPIO state in _enable/disable Mark Brown
2013-01-13 23:35   ` Kim, Milo
2013-01-14  1:42     ` Mark Brown
2013-01-14  2:44       ` Kim, Milo
2013-01-14  2:50         ` Mark Brown
2013-01-21 23:59           ` Kim, Milo

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=A874F61F95741C4A9BA573A70FE3998F69E122AA@DQHE02.ent.ti.com \
    --to=milo.kim@ti.com \
    --cc=axel.lin@ingics.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.