public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Regulator: add suspend-finish API for regulator core.
@ 2011-03-08  2:03 MyungJoo Ham
  2011-03-08 13:38 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: MyungJoo Ham @ 2011-03-08  2:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, kyungmin.park, myungjoo.ham

The regulator core had suspend-prepare that turns off the regulators
when entering a system-wide suspend. However, it did not have
suspend-finish that recovers the change made by suspend-prepare and
depends on machine pm code or the regulator device or driver
doing so.

This patch adds regulator_suspend_finish that pairs with the
previously-existed regulator_suspend_prepare. The function
regulator_suspend_finish turns on the regulators that have always_on set
or positive use_count so that we can recover the regulator states at
resume.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/regulator/core.c          |   24 ++++++++++++++++++++++++
 include/linux/regulator/machine.h |    1 +
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9fa2095..b1e71fd 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2653,6 +2653,30 @@ out:
 EXPORT_SYMBOL_GPL(regulator_suspend_prepare);
 
 /**
+ * regulator_suspend_prepare - resume regulators from system wide suspend
+ *
+ * Turn on regulators that might be turned off by regulator_suspend_prepare.
+ */
+int regulator_suspend_finish(void)
+{
+	struct regulator_dev *rdev;
+	int ret = 0, error;
+
+	mutex_lock(&regulator_list_mutex);
+	list_for_each_entry(rdev, &regulator_list, list) {
+		if ((rdev->use_count > 0  || rdev->constraints->always_on) &&
+				rdev->desc->ops->enable) {
+			error = rdev->desc->ops->enable(rdev);
+			if (error)
+				ret = error;
+		}
+	}
+	mutex_unlock(&regulator_list_mutex);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(regulator_suspend_finish);
+
+/**
  * regulator_has_full_constraints - the system has fully specified constraints
  *
  * Calling this function will cause the regulator API to disable all
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 761c745..c4c4fc4 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -186,6 +186,7 @@ struct regulator_init_data {
 };
 
 int regulator_suspend_prepare(suspend_state_t state);
+int regulator_suspend_finish(void);
 
 #ifdef CONFIG_REGULATOR
 void regulator_has_full_constraints(void);
-- 
1.7.1


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

end of thread, other threads:[~2011-03-09  8:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-08  2:03 [PATCH] Regulator: add suspend-finish API for regulator core MyungJoo Ham
2011-03-08 13:38 ` Mark Brown
2011-03-09  2:35   ` MyungJoo Ham
2011-03-09  2:37   ` [PATCH v2] " MyungJoo Ham
2011-03-09  8:03     ` Igor Grinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox