aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/power/main.c')
-rw-r--r--drivers/base/power/main.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 58a3e572f2c9..86990011277b 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -21,6 +21,7 @@
21#include <linux/kallsyms.h> 21#include <linux/kallsyms.h>
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/resume-trace.h> 25#include <linux/resume-trace.h>
25#include <linux/rwsem.h> 26#include <linux/rwsem.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
@@ -49,6 +50,16 @@ static DEFINE_MUTEX(dpm_list_mtx);
49static bool transition_started; 50static bool transition_started;
50 51
51/** 52/**
53 * device_pm_init - Initialize the PM-related part of a device object
54 * @dev: Device object being initialized.
55 */
56void device_pm_init(struct device *dev)
57{
58 dev->power.status = DPM_ON;
59 pm_runtime_init(dev);
60}
61
62/**
52 * device_pm_lock - lock the list of active devices used by the PM core 63 * device_pm_lock - lock the list of active devices used by the PM core
53 */ 64 */
54void device_pm_lock(void) 65void device_pm_lock(void)
@@ -105,6 +116,7 @@ void device_pm_remove(struct device *dev)
105 mutex_lock(&dpm_list_mtx); 116 mutex_lock(&dpm_list_mtx);
106 list_del_init(&dev->power.entry); 117 list_del_init(&dev->power.entry);
107 mutex_unlock(&dpm_list_mtx); 118 mutex_unlock(&dpm_list_mtx);
119 pm_runtime_remove(dev);
108} 120}
109 121
110/** 122/**
@@ -157,8 +169,9 @@ void device_pm_move_last(struct device *dev)
157 * @ops: PM operations to choose from. 169 * @ops: PM operations to choose from.
158 * @state: PM transition of the system being carried out. 170 * @state: PM transition of the system being carried out.
159 */ 171 */
160static int pm_op(struct device *dev, struct dev_pm_ops *ops, 172static int pm_op(struct device *dev,
161 pm_message_t state) 173 const struct dev_pm_ops *ops,
174 pm_message_t state)
162{ 175{
163 int error = 0; 176 int error = 0;
164 177
@@ -220,7 +233,8 @@ static int pm_op(struct device *dev, struct dev_pm_ops *ops,
220 * The operation is executed with interrupts disabled by the only remaining 233 * The operation is executed with interrupts disabled by the only remaining
221 * functional CPU in the system. 234 * functional CPU in the system.
222 */ 235 */
223static int pm_noirq_op(struct device *dev, struct dev_pm_ops *ops, 236static int pm_noirq_op(struct device *dev,
237 const struct dev_pm_ops *ops,
224 pm_message_t state) 238 pm_message_t state)
225{ 239{
226 int error = 0; 240 int error = 0;
@@ -510,6 +524,7 @@ static void dpm_complete(pm_message_t state)
510 mutex_unlock(&dpm_list_mtx); 524 mutex_unlock(&dpm_list_mtx);
511 525
512 device_complete(dev, state); 526 device_complete(dev, state);
527 pm_runtime_put_noidle(dev);
513 528
514 mutex_lock(&dpm_list_mtx); 529 mutex_lock(&dpm_list_mtx);
515 } 530 }
@@ -755,7 +770,14 @@ static int dpm_prepare(pm_message_t state)
755 dev->power.status = DPM_PREPARING; 770 dev->power.status = DPM_PREPARING;
756 mutex_unlock(&dpm_list_mtx); 771 mutex_unlock(&dpm_list_mtx);
757 772
758 error = device_prepare(dev, state); 773 pm_runtime_get_noresume(dev);
774 if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) {
775 /* Wake-up requested during system sleep transition. */
776 pm_runtime_put_noidle(dev);
777 error = -EBUSY;
778 } else {
779 error = device_prepare(dev, state);
780 }
759 781
760 mutex_lock(&dpm_list_mtx); 782 mutex_lock(&dpm_list_mtx);
761 if (error) { 783 if (error) {