summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-07-13 12:31:52 +0200
committerRafael J. Wysocki <rjw@sisk.pl>2011-07-13 12:31:52 +0200
commit5125bbf3880755419eff68672623cde49c4f31e8 (patch)
tree50c4bfa1745e6d30ca16652a4d2ea848c568eb31 /drivers/base
parent56375fd420f851944960bd53dbb08d674f4d9406 (diff)
downloadop-kernel-dev-5125bbf3880755419eff68672623cde49c4f31e8.zip
op-kernel-dev-5125bbf3880755419eff68672623cde49c4f31e8.tar.gz
PM / Domains: Introduce function to power off all unused PM domains
Add a new function pm_genpd_poweroff_unused() queuing up the execution of pm_genpd_poweroff() for every initialized generic PM domain. Calling it will cause every generic PM domain without devices in use to be powered off. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Magnus Damm <damm@opensource.se>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/domain.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index c3e4e29..c2c537d 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -16,6 +16,9 @@
#include <linux/sched.h>
#include <linux/suspend.h>
+static LIST_HEAD(gpd_list);
+static DEFINE_MUTEX(gpd_list_lock);
+
#ifdef CONFIG_PM
static struct generic_pm_domain *dev_to_genpd(struct device *dev)
@@ -1241,4 +1244,22 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
genpd->domain.ops.restore_noirq = pm_genpd_restore_noirq;
genpd->domain.ops.restore = pm_genpd_restore;
genpd->domain.ops.complete = pm_genpd_complete;
+ mutex_lock(&gpd_list_lock);
+ list_add(&genpd->gpd_list_node, &gpd_list);
+ mutex_unlock(&gpd_list_lock);
+}
+
+/**
+ * pm_genpd_poweroff_unused - Power off all PM domains with no devices in use.
+ */
+void pm_genpd_poweroff_unused(void)
+{
+ struct generic_pm_domain *genpd;
+
+ mutex_lock(&gpd_list_lock);
+
+ list_for_each_entry(genpd, &gpd_list, gpd_list_node)
+ genpd_queue_power_off_work(genpd);
+
+ mutex_unlock(&gpd_list_lock);
}
OpenPOWER on IntegriCloud