aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/power/Makefile2
-rw-r--r--drivers/base/power/power.h5
-rw-r--r--drivers/base/power/runtime.c85
-rw-r--r--drivers/pcmcia/ds.c40
4 files changed, 35 insertions, 97 deletions
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile
index 91f230939c1e..fff178007208 100644
--- a/drivers/base/power/Makefile
+++ b/drivers/base/power/Makefile
@@ -1,5 +1,5 @@
1obj-y := shutdown.o 1obj-y := shutdown.o
2obj-$(CONFIG_PM) += main.o suspend.o resume.o runtime.o sysfs.o 2obj-$(CONFIG_PM) += main.o suspend.o resume.o sysfs.o
3obj-$(CONFIG_PM_TRACE) += trace.o 3obj-$(CONFIG_PM_TRACE) += trace.o
4 4
5ifeq ($(CONFIG_DEBUG_DRIVER),y) 5ifeq ($(CONFIG_DEBUG_DRIVER),y)
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 2760f25b3ac5..591a0dd5deee 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -62,11 +62,6 @@ extern int resume_device(struct device *);
62 */ 62 */
63extern int suspend_device(struct device *, pm_message_t); 63extern int suspend_device(struct device *, pm_message_t);
64 64
65
66/*
67 * runtime.c
68 */
69
70#else /* CONFIG_PM */ 65#else /* CONFIG_PM */
71 66
72 67
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
deleted file mode 100644
index df6174d85866..000000000000
--- a/drivers/base/power/runtime.c
+++ /dev/null
@@ -1,85 +0,0 @@
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.event)
17 return;
18 if (!resume_device(dev))
19 dev->power.power_state = PMSG_ON;
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 mutex_lock(&dpm_mtx);
36 runtime_resume(dev);
37 mutex_unlock(&dpm_mtx);
38}
39EXPORT_SYMBOL(dpm_runtime_resume);
40
41
42/**
43 * dpm_runtime_suspend - Put one device in low-power state.
44 * @dev: Device.
45 * @state: State to enter.
46 */
47
48int dpm_runtime_suspend(struct device * dev, pm_message_t state)
49{
50 int error = 0;
51
52 mutex_lock(&dpm_mtx);
53 if (dev->power.power_state.event == state.event)
54 goto Done;
55
56 if (dev->power.power_state.event)
57 runtime_resume(dev);
58
59 if (!(error = suspend_device(dev, state)))
60 dev->power.power_state = state;
61 Done:
62 mutex_unlock(&dpm_mtx);
63 return error;
64}
65EXPORT_SYMBOL(dpm_runtime_suspend);
66
67
68#if 0
69/**
70 * dpm_set_power_state - Update power_state field.
71 * @dev: Device.
72 * @state: Power state device is in.
73 *
74 * This is an update mechanism for drivers to notify the core
75 * what power state a device is in. Device probing code may not
76 * always be able to tell, but we need accurate information to
77 * work reliably.
78 */
79void dpm_set_power_state(struct device * dev, pm_message_t state)
80{
81 mutex_lock(&dpm_mtx);
82 dev->power.power_state = state;
83 mutex_unlock(&dpm_mtx);
84}
85#endif /* 0 */
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 143c6efc478a..a99607142fc8 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1127,6 +1127,34 @@ static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp,
1127 1127
1128#endif 1128#endif
1129 1129
1130/************************ runtime PM support ***************************/
1131
1132static int pcmcia_dev_suspend(struct device *dev, pm_message_t state);
1133static int pcmcia_dev_resume(struct device *dev);
1134
1135static int runtime_suspend(struct device *dev)
1136{
1137 int rc;
1138
1139 down(&dev->sem);
1140 rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND);
1141 up(&dev->sem);
1142 if (!rc)
1143 dev->power.power_state.event = PM_EVENT_SUSPEND;
1144 return rc;
1145}
1146
1147static void runtime_resume(struct device *dev)
1148{
1149 int rc;
1150
1151 down(&dev->sem);
1152 rc = pcmcia_dev_resume(dev);
1153 up(&dev->sem);
1154 if (!rc)
1155 dev->power.power_state.event = PM_EVENT_ON;
1156}
1157
1130/************************ per-device sysfs output ***************************/ 1158/************************ per-device sysfs output ***************************/
1131 1159
1132#define pcmcia_device_attr(field, test, format) \ 1160#define pcmcia_device_attr(field, test, format) \
@@ -1173,9 +1201,9 @@ static ssize_t pcmcia_store_pm_state(struct device *dev, struct device_attribute
1173 return -EINVAL; 1201 return -EINVAL;
1174 1202
1175 if ((!p_dev->suspended) && !strncmp(buf, "off", 3)) 1203 if ((!p_dev->suspended) && !strncmp(buf, "off", 3))
1176 ret = dpm_runtime_suspend(dev, PMSG_SUSPEND); 1204 ret = runtime_suspend(dev);
1177 else if (p_dev->suspended && !strncmp(buf, "on", 2)) 1205 else if (p_dev->suspended && !strncmp(buf, "on", 2))
1178 dpm_runtime_resume(dev); 1206 runtime_resume(dev);
1179 1207
1180 return ret ? ret : count; 1208 return ret ? ret : count;
1181} 1209}
@@ -1312,10 +1340,10 @@ static int pcmcia_bus_suspend_callback(struct device *dev, void * _data)
1312 struct pcmcia_socket *skt = _data; 1340 struct pcmcia_socket *skt = _data;
1313 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1341 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1314 1342
1315 if (p_dev->socket != skt) 1343 if (p_dev->socket != skt || p_dev->suspended)
1316 return 0; 1344 return 0;
1317 1345
1318 return dpm_runtime_suspend(dev, PMSG_SUSPEND); 1346 return runtime_suspend(dev);
1319} 1347}
1320 1348
1321static int pcmcia_bus_resume_callback(struct device *dev, void * _data) 1349static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
@@ -1323,10 +1351,10 @@ static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
1323 struct pcmcia_socket *skt = _data; 1351 struct pcmcia_socket *skt = _data;
1324 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1352 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1325 1353
1326 if (p_dev->socket != skt) 1354 if (p_dev->socket != skt || !p_dev->suspended)
1327 return 0; 1355 return 0;
1328 1356
1329 dpm_runtime_resume(dev); 1357 runtime_resume(dev);
1330 1358
1331 return 0; 1359 return 0;
1332} 1360}