aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/resume.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/base/power/resume.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/base/power/resume.c')
-rw-r--r--drivers/base/power/resume.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c
new file mode 100644
index 000000000000..f8f5055754d6
--- /dev/null
+++ b/drivers/base/power/resume.c
@@ -0,0 +1,112 @@
1/*
2 * resume.c - Functions for waking devices up.
3 *
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Labs
6 *
7 * This file is released under the GPLv2
8 *
9 */
10
11#include <linux/device.h>
12#include "power.h"
13
14extern int sysdev_resume(void);
15
16
17/**
18 * resume_device - Restore state for one device.
19 * @dev: Device.
20 *
21 */
22
23int resume_device(struct device * dev)
24{
25 if (dev->bus && dev->bus->resume)
26 return dev->bus->resume(dev);
27 return 0;
28}
29
30
31
32void dpm_resume(void)
33{
34 down(&dpm_list_sem);
35 while(!list_empty(&dpm_off)) {
36 struct list_head * entry = dpm_off.next;
37 struct device * dev = to_device(entry);
38
39 get_device(dev);
40 list_del_init(entry);
41 list_add_tail(entry, &dpm_active);
42
43 up(&dpm_list_sem);
44 if (!dev->power.prev_state)
45 resume_device(dev);
46 down(&dpm_list_sem);
47 put_device(dev);
48 }
49 up(&dpm_list_sem);
50}
51
52
53/**
54 * device_resume - Restore state of each device in system.
55 *
56 * Walk the dpm_off list, remove each entry, resume the device,
57 * then add it to the dpm_active list.
58 */
59
60void device_resume(void)
61{
62 down(&dpm_sem);
63 dpm_resume();
64 up(&dpm_sem);
65}
66
67EXPORT_SYMBOL_GPL(device_resume);
68
69
70/**
71 * device_power_up_irq - Power on some devices.
72 *
73 * Walk the dpm_off_irq list and power each device up. This
74 * is used for devices that required they be powered down with
75 * interrupts disabled. As devices are powered on, they are moved to
76 * the dpm_suspended list.
77 *
78 * Interrupts must be disabled when calling this.
79 */
80
81void dpm_power_up(void)
82{
83 while(!list_empty(&dpm_off_irq)) {
84 struct list_head * entry = dpm_off_irq.next;
85 struct device * dev = to_device(entry);
86
87 get_device(dev);
88 list_del_init(entry);
89 list_add_tail(entry, &dpm_active);
90 resume_device(dev);
91 put_device(dev);
92 }
93}
94
95
96/**
97 * device_pm_power_up - Turn on all devices that need special attention.
98 *
99 * Power on system devices then devices that required we shut them down
100 * with interrupts disabled.
101 * Called with interrupts disabled.
102 */
103
104void device_power_up(void)
105{
106 sysdev_resume();
107 dpm_power_up();
108}
109
110EXPORT_SYMBOL_GPL(device_power_up);
111
112