NTFS: Fix the definition of the CHKD ntfs record magic. It had an off by
[linux-2.6/libata-dev.git] / drivers / base / power / resume.c
blob0a7aa07b9a2a600cc9b52992b8e0f0d44216af17
1 /*
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
9 */
11 #include <linux/device.h>
12 #include "power.h"
14 extern int sysdev_resume(void);
17 /**
18 * resume_device - Restore state for one device.
19 * @dev: Device.
23 int resume_device(struct device * dev)
25 int error = 0;
27 down(&dev->sem);
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);
39 up(&dev->sem);
40 return error;
45 void dpm_resume(void)
47 down(&dpm_list_sem);
48 while(!list_empty(&dpm_off)) {
49 struct list_head * entry = dpm_off.next;
50 struct device * dev = to_device(entry);
52 get_device(dev);
53 list_del_init(entry);
54 list_add_tail(entry, &dpm_active);
56 up(&dpm_list_sem);
57 if (!dev->power.prev_state.event)
58 resume_device(dev);
59 down(&dpm_list_sem);
60 put_device(dev);
62 up(&dpm_list_sem);
66 /**
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)
75 down(&dpm_sem);
76 dpm_resume();
77 up(&dpm_sem);
80 EXPORT_SYMBOL_GPL(device_resume);
83 /**
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);
100 get_device(dev);
101 list_del_init(entry);
102 list_add_tail(entry, &dpm_active);
103 resume_device(dev);
104 put_device(dev);
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)
119 sysdev_resume();
120 dpm_power_up();
123 EXPORT_SYMBOL_GPL(device_power_up);