2 * resume.c - Functions for waking devices up.
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Labs
7 * This file is released under the GPLv2
11 #include <linux/device.h>
12 #include <linux/resume-trace.h>
18 * resume_device - Restore state for one device.
23 int resume_device(struct device
* dev
)
32 if (dev
->bus
&& dev
->bus
->resume
) {
33 dev_dbg(dev
,"resuming\n");
34 error
= dev
->bus
->resume(dev
);
37 if (!error
&& dev
->type
&& dev
->type
->resume
) {
38 dev_dbg(dev
,"resuming\n");
39 error
= dev
->type
->resume(dev
);
42 if (!error
&& dev
->class && dev
->class->resume
) {
43 dev_dbg(dev
,"class resume\n");
44 error
= dev
->class->resume(dev
);
54 static int resume_device_early(struct device
* dev
)
60 if (dev
->bus
&& dev
->bus
->resume_early
) {
61 dev_dbg(dev
,"EARLY resume\n");
62 error
= dev
->bus
->resume_early(dev
);
69 * Resume the devices that have either not gone through
70 * the late suspend, or that did go through it but also
71 * went through the early resume
75 mutex_lock(&dpm_list_mtx
);
76 while(!list_empty(&dpm_off
)) {
77 struct list_head
* entry
= dpm_off
.next
;
78 struct device
* dev
= to_device(entry
);
81 list_move_tail(entry
, &dpm_active
);
83 mutex_unlock(&dpm_list_mtx
);
85 mutex_lock(&dpm_list_mtx
);
88 mutex_unlock(&dpm_list_mtx
);
93 * device_resume - Restore state of each device in system.
95 * Walk the dpm_off list, remove each entry, resume the device,
96 * then add it to the dpm_active list.
99 void device_resume(void)
102 mutex_lock(&dpm_mtx
);
104 mutex_unlock(&dpm_mtx
);
107 EXPORT_SYMBOL_GPL(device_resume
);
111 * dpm_power_up - Power on some devices.
113 * Walk the dpm_off_irq list and power each device up. This
114 * is used for devices that required they be powered down with
115 * interrupts disabled. As devices are powered on, they are moved
116 * to the dpm_active list.
118 * Interrupts must be disabled when calling this.
121 void dpm_power_up(void)
123 while(!list_empty(&dpm_off_irq
)) {
124 struct list_head
* entry
= dpm_off_irq
.next
;
125 struct device
* dev
= to_device(entry
);
127 list_move_tail(entry
, &dpm_off
);
128 resume_device_early(dev
);
134 * device_power_up - Turn on all devices that need special attention.
136 * Power on system devices then devices that required we shut them down
137 * with interrupts disabled.
138 * Called with interrupts disabled.
141 void device_power_up(void)
147 EXPORT_SYMBOL_GPL(device_power_up
);