[PATCH] drivers/base/: proper prototypes
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / base / power / resume.c
blob317edbf0feca6b383fb95980968c28b9947e2970
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 "../base.h"
13 #include "power.h"
16 /**
17 * resume_device - Restore state for one device.
18 * @dev: Device.
22 int resume_device(struct device * dev)
24 int error = 0;
26 down(&dev->sem);
27 if (dev->power.pm_parent
28 && dev->power.pm_parent->power.power_state.event) {
29 dev_err(dev, "PM: resume from %d, parent %s still %d\n",
30 dev->power.power_state.event,
31 dev->power.pm_parent->bus_id,
32 dev->power.pm_parent->power.power_state.event);
34 if (dev->bus && dev->bus->resume) {
35 dev_dbg(dev,"resuming\n");
36 error = dev->bus->resume(dev);
38 up(&dev->sem);
39 return error;
44 void dpm_resume(void)
46 down(&dpm_list_sem);
47 while(!list_empty(&dpm_off)) {
48 struct list_head * entry = dpm_off.next;
49 struct device * dev = to_device(entry);
51 get_device(dev);
52 list_del_init(entry);
53 list_add_tail(entry, &dpm_active);
55 up(&dpm_list_sem);
56 if (!dev->power.prev_state.event)
57 resume_device(dev);
58 down(&dpm_list_sem);
59 put_device(dev);
61 up(&dpm_list_sem);
65 /**
66 * device_resume - Restore state of each device in system.
68 * Walk the dpm_off list, remove each entry, resume the device,
69 * then add it to the dpm_active list.
72 void device_resume(void)
74 down(&dpm_sem);
75 dpm_resume();
76 up(&dpm_sem);
79 EXPORT_SYMBOL_GPL(device_resume);
82 /**
83 * device_power_up_irq - Power on some devices.
85 * Walk the dpm_off_irq list and power each device up. This
86 * is used for devices that required they be powered down with
87 * interrupts disabled. As devices are powered on, they are moved to
88 * the dpm_suspended list.
90 * Interrupts must be disabled when calling this.
93 void dpm_power_up(void)
95 while(!list_empty(&dpm_off_irq)) {
96 struct list_head * entry = dpm_off_irq.next;
97 struct device * dev = to_device(entry);
99 get_device(dev);
100 list_del_init(entry);
101 list_add_tail(entry, &dpm_active);
102 resume_device(dev);
103 put_device(dev);
109 * device_pm_power_up - Turn on all devices that need special attention.
111 * Power on system devices then devices that required we shut them down
112 * with interrupts disabled.
113 * Called with interrupts disabled.
116 void device_power_up(void)
118 sysdev_resume();
119 dpm_power_up();
122 EXPORT_SYMBOL_GPL(device_power_up);