[ARM] 4595/1: ns9xxx: define registers as void __iomem * instead of volatile u32
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / base / power / resume.c
blob00fd84ae6e66f955855f39286b66632c50b0e3dc
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 <linux/resume-trace.h>
13 #include "../base.h"
14 #include "power.h"
17 /**
18 * resume_device - Restore state for one device.
19 * @dev: Device.
23 int resume_device(struct device * dev)
25 int error = 0;
27 TRACE_DEVICE(dev);
28 TRACE_RESUME(0);
30 down(&dev->sem);
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);
47 up(&dev->sem);
49 TRACE_RESUME(error);
50 return error;
54 static int resume_device_early(struct device * dev)
56 int error = 0;
58 TRACE_DEVICE(dev);
59 TRACE_RESUME(0);
60 if (dev->bus && dev->bus->resume_early) {
61 dev_dbg(dev,"EARLY resume\n");
62 error = dev->bus->resume_early(dev);
64 TRACE_RESUME(error);
65 return error;
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
73 void dpm_resume(void)
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);
80 get_device(dev);
81 list_move_tail(entry, &dpm_active);
83 mutex_unlock(&dpm_list_mtx);
84 resume_device(dev);
85 mutex_lock(&dpm_list_mtx);
86 put_device(dev);
88 mutex_unlock(&dpm_list_mtx);
92 /**
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)
101 might_sleep();
102 mutex_lock(&dpm_mtx);
103 dpm_resume();
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)
143 sysdev_resume();
144 dpm_power_up();
147 EXPORT_SYMBOL_GPL(device_power_up);