diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-07-13 06:31:52 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-07-13 06:31:52 -0400 |
commit | 5125bbf3880755419eff68672623cde49c4f31e8 (patch) | |
tree | 50c4bfa1745e6d30ca16652a4d2ea848c568eb31 /drivers/base/power | |
parent | 56375fd420f851944960bd53dbb08d674f4d9406 (diff) |
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/power')
-rw-r--r-- | drivers/base/power/domain.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index c3e4e2934e16..c2c537de22b6 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c | |||
@@ -16,6 +16,9 @@ | |||
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/suspend.h> | 17 | #include <linux/suspend.h> |
18 | 18 | ||
19 | static LIST_HEAD(gpd_list); | ||
20 | static DEFINE_MUTEX(gpd_list_lock); | ||
21 | |||
19 | #ifdef CONFIG_PM | 22 | #ifdef CONFIG_PM |
20 | 23 | ||
21 | static struct generic_pm_domain *dev_to_genpd(struct device *dev) | 24 | static struct generic_pm_domain *dev_to_genpd(struct device *dev) |
@@ -1241,4 +1244,22 @@ void pm_genpd_init(struct generic_pm_domain *genpd, | |||
1241 | genpd->domain.ops.restore_noirq = pm_genpd_restore_noirq; | 1244 | genpd->domain.ops.restore_noirq = pm_genpd_restore_noirq; |
1242 | genpd->domain.ops.restore = pm_genpd_restore; | 1245 | genpd->domain.ops.restore = pm_genpd_restore; |
1243 | genpd->domain.ops.complete = pm_genpd_complete; | 1246 | genpd->domain.ops.complete = pm_genpd_complete; |
1247 | mutex_lock(&gpd_list_lock); | ||
1248 | list_add(&genpd->gpd_list_node, &gpd_list); | ||
1249 | mutex_unlock(&gpd_list_lock); | ||
1250 | } | ||
1251 | |||
1252 | /** | ||
1253 | * pm_genpd_poweroff_unused - Power off all PM domains with no devices in use. | ||
1254 | */ | ||
1255 | void pm_genpd_poweroff_unused(void) | ||
1256 | { | ||
1257 | struct generic_pm_domain *genpd; | ||
1258 | |||
1259 | mutex_lock(&gpd_list_lock); | ||
1260 | |||
1261 | list_for_each_entry(genpd, &gpd_list, gpd_list_node) | ||
1262 | genpd_queue_power_off_work(genpd); | ||
1263 | |||
1264 | mutex_unlock(&gpd_list_lock); | ||
1244 | } | 1265 | } |