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->parent && dev->parent->power.power_state.event) {
33 dev_err(dev, "PM: resume from %d, parent %s still %d\n",
34 dev->power.power_state.event,
36 dev->parent->power.power_state.event);
39 if (dev->bus && dev->bus->resume) {
40 dev_dbg(dev,"resuming\n");
41 error = dev->bus->resume(dev);
44 if (!error && dev->type && dev->type->resume) {
45 dev_dbg(dev,"resuming\n");
46 error = dev->type->resume(dev);
49 if (!error && dev->class && dev->class->resume) {
50 dev_dbg(dev,"class resume\n");
51 error = dev->class->resume(dev);
61 static int resume_device_early(struct device * dev)
67 if (dev->bus && dev->bus->resume_early) {
68 dev_dbg(dev,"EARLY resume\n");
69 error = dev->bus->resume_early(dev);
76 * Resume the devices that have either not gone through
77 * the late suspend, or that did go through it but also
78 * went through the early resume
82 mutex_lock(&dpm_list_mtx);
83 while(!list_empty(&dpm_off)) {
84 struct list_head * entry = dpm_off.next;
85 struct device * dev = to_device(entry);
88 list_move_tail(entry, &dpm_active);
90 mutex_unlock(&dpm_list_mtx);
92 mutex_lock(&dpm_list_mtx);
95 mutex_unlock(&dpm_list_mtx);
100 * device_resume - Restore state of each device in system.
102 * Walk the dpm_off list, remove each entry, resume the device,
103 * then add it to the dpm_active list.
106 void device_resume(void)
109 mutex_lock(&dpm_mtx);
111 mutex_unlock(&dpm_mtx);
114 EXPORT_SYMBOL_GPL(device_resume);
118 * dpm_power_up - Power on some devices.
120 * Walk the dpm_off_irq list and power each device up. This
121 * is used for devices that required they be powered down with
122 * interrupts disabled. As devices are powered on, they are moved
123 * to the dpm_active list.
125 * Interrupts must be disabled when calling this.
128 void dpm_power_up(void)
130 while(!list_empty(&dpm_off_irq)) {
131 struct list_head * entry = dpm_off_irq.next;
132 struct device * dev = to_device(entry);
134 list_move_tail(entry, &dpm_off);
135 resume_device_early(dev);
141 * device_power_up - Turn on all devices that need special attention.
143 * Power on system devices then devices that required we shut them down
144 * with interrupts disabled.
145 * Called with interrupts disabled.
148 void device_power_up(void)
154 EXPORT_SYMBOL_GPL(device_power_up);