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>
14 extern int sysdev_resume(void);
18 * resume_device - Restore state for one device.
23 int resume_device(struct device
* dev
)
28 if (dev
->power
.pm_parent
29 && dev
->power
.pm_parent
->power
.power_state
.event
) {
30 dev_err(dev
, "PM: resume from %d, parent %s still %d\n",
31 dev
->power
.power_state
.event
,
32 dev
->power
.pm_parent
->bus_id
,
33 dev
->power
.pm_parent
->power
.power_state
.event
);
35 if (dev
->bus
&& dev
->bus
->resume
) {
36 dev_dbg(dev
,"resuming\n");
37 error
= dev
->bus
->resume(dev
);
48 while(!list_empty(&dpm_off
)) {
49 struct list_head
* entry
= dpm_off
.next
;
50 struct device
* dev
= to_device(entry
);
54 list_add_tail(entry
, &dpm_active
);
57 if (!dev
->power
.prev_state
.event
)
67 * device_resume - Restore state of each device in system.
69 * Walk the dpm_off list, remove each entry, resume the device,
70 * then add it to the dpm_active list.
73 void device_resume(void)
80 EXPORT_SYMBOL_GPL(device_resume
);
84 * device_power_up_irq - Power on some devices.
86 * Walk the dpm_off_irq list and power each device up. This
87 * is used for devices that required they be powered down with
88 * interrupts disabled. As devices are powered on, they are moved to
89 * the dpm_suspended list.
91 * Interrupts must be disabled when calling this.
94 void dpm_power_up(void)
96 while(!list_empty(&dpm_off_irq
)) {
97 struct list_head
* entry
= dpm_off_irq
.next
;
98 struct device
* dev
= to_device(entry
);
101 list_del_init(entry
);
102 list_add_tail(entry
, &dpm_active
);
110 * device_pm_power_up - Turn on all devices that need special attention.
112 * Power on system devices then devices that required we shut them down
113 * with interrupts disabled.
114 * Called with interrupts disabled.
117 void device_power_up(void)
123 EXPORT_SYMBOL_GPL(device_power_up
);