All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] regulator-core: update all enable GPIO state in _enable/disable
@ 2013-01-10  9:46 Kim, Milo
  2013-01-13 22:42 ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Kim, Milo @ 2013-01-10  9:46 UTC (permalink / raw)
  To: Mark Brown; +Cc: Axel Lin, Girdwood, Liam, linux-kernel@vger.kernel.org

 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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-01-21 23:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-10  9:46 [PATCH 2/3] regulator-core: update all enable GPIO state in _enable/disable Kim, Milo
2013-01-13 22:42 ` 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

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.