aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/resume.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/power/resume.c')
-rw-r--r--drivers/base/power/resume.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c
index 317edbf0feca..020be36705a6 100644
--- a/drivers/base/power/resume.c
+++ b/drivers/base/power/resume.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/resume-trace.h>
12#include "../base.h" 13#include "../base.h"
13#include "power.h" 14#include "power.h"
14 15
@@ -23,6 +24,8 @@ int resume_device(struct device * dev)
23{ 24{
24 int error = 0; 25 int error = 0;
25 26
27 TRACE_DEVICE(dev);
28 TRACE_RESUME(0);
26 down(&dev->sem); 29 down(&dev->sem);
27 if (dev->power.pm_parent 30 if (dev->power.pm_parent
28 && dev->power.pm_parent->power.power_state.event) { 31 && dev->power.pm_parent->power.power_state.event) {
@@ -35,12 +38,35 @@ int resume_device(struct device * dev)
35 dev_dbg(dev,"resuming\n"); 38 dev_dbg(dev,"resuming\n");
36 error = dev->bus->resume(dev); 39 error = dev->bus->resume(dev);
37 } 40 }
41 if (dev->class && dev->class->resume) {
42 dev_dbg(dev,"class resume\n");
43 error = dev->class->resume(dev);
44 }
38 up(&dev->sem); 45 up(&dev->sem);
46 TRACE_RESUME(error);
39 return error; 47 return error;
40} 48}
41 49
42 50
51static int resume_device_early(struct device * dev)
52{
53 int error = 0;
43 54
55 TRACE_DEVICE(dev);
56 TRACE_RESUME(0);
57 if (dev->bus && dev->bus->resume_early) {
58 dev_dbg(dev,"EARLY resume\n");
59 error = dev->bus->resume_early(dev);
60 }
61 TRACE_RESUME(error);
62 return error;
63}
64
65/*
66 * Resume the devices that have either not gone through
67 * the late suspend, or that did go through it but also
68 * went through the early resume
69 */
44void dpm_resume(void) 70void dpm_resume(void)
45{ 71{
46 down(&dpm_list_sem); 72 down(&dpm_list_sem);
@@ -49,8 +75,7 @@ void dpm_resume(void)
49 struct device * dev = to_device(entry); 75 struct device * dev = to_device(entry);
50 76
51 get_device(dev); 77 get_device(dev);
52 list_del_init(entry); 78 list_move_tail(entry, &dpm_active);
53 list_add_tail(entry, &dpm_active);
54 79
55 up(&dpm_list_sem); 80 up(&dpm_list_sem);
56 if (!dev->power.prev_state.event) 81 if (!dev->power.prev_state.event)
@@ -71,6 +96,7 @@ void dpm_resume(void)
71 96
72void device_resume(void) 97void device_resume(void)
73{ 98{
99 might_sleep();
74 down(&dpm_sem); 100 down(&dpm_sem);
75 dpm_resume(); 101 dpm_resume();
76 up(&dpm_sem); 102 up(&dpm_sem);
@@ -80,12 +106,12 @@ EXPORT_SYMBOL_GPL(device_resume);
80 106
81 107
82/** 108/**
83 * device_power_up_irq - Power on some devices. 109 * dpm_power_up - Power on some devices.
84 * 110 *
85 * Walk the dpm_off_irq list and power each device up. This 111 * Walk the dpm_off_irq list and power each device up. This
86 * is used for devices that required they be powered down with 112 * is used for devices that required they be powered down with
87 * interrupts disabled. As devices are powered on, they are moved to 113 * interrupts disabled. As devices are powered on, they are moved
88 * the dpm_suspended list. 114 * to the dpm_active list.
89 * 115 *
90 * Interrupts must be disabled when calling this. 116 * Interrupts must be disabled when calling this.
91 */ 117 */
@@ -96,17 +122,14 @@ void dpm_power_up(void)
96 struct list_head * entry = dpm_off_irq.next; 122 struct list_head * entry = dpm_off_irq.next;
97 struct device * dev = to_device(entry); 123 struct device * dev = to_device(entry);
98 124
99 get_device(dev); 125 list_move_tail(entry, &dpm_off);
100 list_del_init(entry); 126 resume_device_early(dev);
101 list_add_tail(entry, &dpm_active);
102 resume_device(dev);
103 put_device(dev);
104 } 127 }
105} 128}
106 129
107 130
108/** 131/**
109 * device_pm_power_up - Turn on all devices that need special attention. 132 * device_power_up - Turn on all devices that need special attention.
110 * 133 *
111 * Power on system devices then devices that required we shut them down 134 * Power on system devices then devices that required we shut them down
112 * with interrupts disabled. 135 * with interrupts disabled.