aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/runtime.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/runtime.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/runtime.c')
-rw-r--r--drivers/base/power/runtime.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
new file mode 100644
index 000000000000..325962d80191
--- /dev/null
+++ b/drivers/base/power/runtime.c
@@ -0,0 +1,81 @@
1/*
2 * drivers/base/power/runtime.c - Handling dynamic device power management.
3 *
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Lab
6 *
7 */
8
9#include <linux/device.h>
10#include "power.h"
11
12
13static void runtime_resume(struct device * dev)
14{
15 dev_dbg(dev, "resuming\n");
16 if (!dev->power.power_state)
17 return;
18 if (!resume_device(dev))
19 dev->power.power_state = 0;
20}
21
22
23/**
24 * dpm_runtime_resume - Power one device back on.
25 * @dev: Device.
26 *
27 * Bring one device back to the on state by first powering it
28 * on, then restoring state. We only operate on devices that aren't
29 * already on.
30 * FIXME: We need to handle devices that are in an unknown state.
31 */
32
33void dpm_runtime_resume(struct device * dev)
34{
35 down(&dpm_sem);
36 runtime_resume(dev);
37 up(&dpm_sem);
38}
39
40
41/**
42 * dpm_runtime_suspend - Put one device in low-power state.
43 * @dev: Device.
44 * @state: State to enter.
45 */
46
47int dpm_runtime_suspend(struct device * dev, pm_message_t state)
48{
49 int error = 0;
50
51 down(&dpm_sem);
52 if (dev->power.power_state == state)
53 goto Done;
54
55 if (dev->power.power_state)
56 runtime_resume(dev);
57
58 if (!(error = suspend_device(dev, state)))
59 dev->power.power_state = state;
60 Done:
61 up(&dpm_sem);
62 return error;
63}
64
65
66/**
67 * dpm_set_power_state - Update power_state field.
68 * @dev: Device.
69 * @state: Power state device is in.
70 *
71 * This is an update mechanism for drivers to notify the core
72 * what power state a device is in. Device probing code may not
73 * always be able to tell, but we need accurate information to
74 * work reliably.
75 */
76void dpm_set_power_state(struct device * dev, pm_message_t state)
77{
78 down(&dpm_sem);
79 dev->power.power_state = state;
80 up(&dpm_sem);
81}