diff options
Diffstat (limited to 'drivers/base/power/sysfs.c')
-rw-r--r-- | drivers/base/power/sysfs.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 40d7242a07c1..2d47517dbe32 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c | |||
@@ -7,22 +7,29 @@ | |||
7 | #include "power.h" | 7 | #include "power.h" |
8 | 8 | ||
9 | 9 | ||
10 | #ifdef CONFIG_PM_SYSFS_DEPRECATED | ||
11 | |||
10 | /** | 12 | /** |
11 | * state - Control current power state of device | 13 | * state - Control current power state of device |
12 | * | 14 | * |
13 | * show() returns the current power state of the device. '0' indicates | 15 | * show() returns the current power state of the device. '0' indicates |
14 | * the device is on. Other values (1-3) indicate the device is in a low | 16 | * the device is on. Other values (2) indicate the device is in some low |
15 | * power state. | 17 | * power state. |
16 | * | 18 | * |
17 | * store() sets the current power state, which is an integer value | 19 | * store() sets the current power state, which is an integer valued |
18 | * between 0-3. If the device is on ('0'), and the value written is | 20 | * 0, 2, or 3. Devices with bus.suspend_late(), or bus.resume_early() |
19 | * greater than 0, then the device is placed directly into the low-power | 21 | * methods fail this operation; those methods couldn't be called. |
20 | * state (via its driver's ->suspend() method). | 22 | * Otherwise, |
21 | * If the device is currently in a low-power state, and the value is 0, | 23 | * |
22 | * the device is powered back on (via the ->resume() method). | 24 | * - If the recorded dev->power.power_state.event matches the |
23 | * If the device is in a low-power state, and a different low-power state | 25 | * target value, nothing is done. |
24 | * is requested, the device is first resumed, then suspended into the new | 26 | * - If the recorded event code is nonzero, the device is reactivated |
25 | * low-power state. | 27 | * by calling bus.resume() and/or class.resume(). |
28 | * - If the target value is nonzero, the device is suspended by | ||
29 | * calling class.suspend() and/or bus.suspend() with event code | ||
30 | * PM_EVENT_SUSPEND. | ||
31 | * | ||
32 | * This mechanism is DEPRECATED and should only be used for testing. | ||
26 | */ | 33 | */ |
27 | 34 | ||
28 | static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf) | 35 | static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf) |
@@ -38,6 +45,10 @@ static ssize_t state_store(struct device * dev, struct device_attribute *attr, c | |||
38 | pm_message_t state; | 45 | pm_message_t state; |
39 | int error = -EINVAL; | 46 | int error = -EINVAL; |
40 | 47 | ||
48 | /* disallow incomplete suspend sequences */ | ||
49 | if (dev->bus && (dev->bus->suspend_late || dev->bus->resume_early)) | ||
50 | return error; | ||
51 | |||
41 | state.event = PM_EVENT_SUSPEND; | 52 | state.event = PM_EVENT_SUSPEND; |
42 | /* Older apps expected to write "3" here - confused with PCI D3 */ | 53 | /* Older apps expected to write "3" here - confused with PCI D3 */ |
43 | if ((n == 1) && !strcmp(buf, "3")) | 54 | if ((n == 1) && !strcmp(buf, "3")) |
@@ -57,6 +68,8 @@ static ssize_t state_store(struct device * dev, struct device_attribute *attr, c | |||
57 | static DEVICE_ATTR(state, 0644, state_show, state_store); | 68 | static DEVICE_ATTR(state, 0644, state_show, state_store); |
58 | 69 | ||
59 | 70 | ||
71 | #endif /* CONFIG_PM_SYSFS_DEPRECATED */ | ||
72 | |||
60 | /* | 73 | /* |
61 | * wakeup - Report/change current wakeup option for device | 74 | * wakeup - Report/change current wakeup option for device |
62 | * | 75 | * |
@@ -130,7 +143,9 @@ static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); | |||
130 | 143 | ||
131 | 144 | ||
132 | static struct attribute * power_attrs[] = { | 145 | static struct attribute * power_attrs[] = { |
146 | #ifdef CONFIG_PM_SYSFS_DEPRECATED | ||
133 | &dev_attr_state.attr, | 147 | &dev_attr_state.attr, |
148 | #endif | ||
134 | &dev_attr_wakeup.attr, | 149 | &dev_attr_wakeup.attr, |
135 | NULL, | 150 | NULL, |
136 | }; | 151 | }; |