aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/main.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-09-29 16:29:44 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-10-04 15:54:26 -0400
commit1a9a91525d806f2b3bd8b57b963755a96fd36ce2 (patch)
tree511db2ab0871872bce759d35b7ffd22b9d7fc3f5 /drivers/base/power/main.c
parentb66213cdb002b08b29603d488c451dfe25e2ca20 (diff)
PM / QoS: Add function dev_pm_qos_read_value() (v3)
To read the current PM QoS value for a given device we need to make sure that the device's power.constraints object won't be removed while we're doing that. For this reason, put the operation under dev->power.lock and acquire the lock around the initialization and removal of power.constraints. Moreover, since we're using the value of power.constraints to determine whether or not the object is present, the power.constraints_state field isn't necessary any more and may be removed. However, dev_pm_qos_add_request() needs to check if the device is being removed from the system before allocating a new PM QoS constraints object for it, so make it use the power.power_state field of struct device for this purpose. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base/power/main.c')
-rw-r--r--drivers/base/power/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 956443f86254..c6291ab725a3 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -22,7 +22,6 @@
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/pm.h> 23#include <linux/pm.h>
24#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
25#include <linux/pm_qos.h>
26#include <linux/resume-trace.h> 25#include <linux/resume-trace.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/sched.h> 27#include <linux/sched.h>
@@ -66,6 +65,7 @@ void device_pm_init(struct device *dev)
66 spin_lock_init(&dev->power.lock); 65 spin_lock_init(&dev->power.lock);
67 pm_runtime_init(dev); 66 pm_runtime_init(dev);
68 INIT_LIST_HEAD(&dev->power.entry); 67 INIT_LIST_HEAD(&dev->power.entry);
68 dev->power.power_state = PMSG_INVALID;
69} 69}
70 70
71/** 71/**
@@ -97,8 +97,8 @@ void device_pm_add(struct device *dev)
97 dev_warn(dev, "parent %s should not be sleeping\n", 97 dev_warn(dev, "parent %s should not be sleeping\n",
98 dev_name(dev->parent)); 98 dev_name(dev->parent));
99 list_add_tail(&dev->power.entry, &dpm_list); 99 list_add_tail(&dev->power.entry, &dpm_list);
100 mutex_unlock(&dpm_list_mtx);
101 dev_pm_qos_constraints_init(dev); 100 dev_pm_qos_constraints_init(dev);
101 mutex_unlock(&dpm_list_mtx);
102} 102}
103 103
104/** 104/**
@@ -109,9 +109,9 @@ void device_pm_remove(struct device *dev)
109{ 109{
110 pr_debug("PM: Removing info for %s:%s\n", 110 pr_debug("PM: Removing info for %s:%s\n",
111 dev->bus ? dev->bus->name : "No Bus", dev_name(dev)); 111 dev->bus ? dev->bus->name : "No Bus", dev_name(dev));
112 dev_pm_qos_constraints_destroy(dev);
113 complete_all(&dev->power.completion); 112 complete_all(&dev->power.completion);
114 mutex_lock(&dpm_list_mtx); 113 mutex_lock(&dpm_list_mtx);
114 dev_pm_qos_constraints_destroy(dev);
115 list_del_init(&dev->power.entry); 115 list_del_init(&dev->power.entry);
116 mutex_unlock(&dpm_list_mtx); 116 mutex_unlock(&dpm_list_mtx);
117 device_wakeup_disable(dev); 117 device_wakeup_disable(dev);