aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/power/sysfs.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 40d7242a07c1..e55b3c2779e9 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -11,18 +11,23 @@
11 * state - Control current power state of device 11 * state - Control current power state of device
12 * 12 *
13 * show() returns the current power state of the device. '0' indicates 13 * 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 14 * the device is on. Other values (2) indicate the device is in some low
15 * power state. 15 * power state.
16 * 16 *
17 * store() sets the current power state, which is an integer value 17 * 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 18 * 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 19 * methods fail this operation; those methods couldn't be called.
20 * state (via its driver's ->suspend() method). 20 * Otherwise,
21 * If the device is currently in a low-power state, and the value is 0, 21 *
22 * the device is powered back on (via the ->resume() method). 22 * - 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 23 * target value, nothing is done.
24 * is requested, the device is first resumed, then suspended into the new 24 * - If the recorded event code is nonzero, the device is reactivated
25 * low-power state. 25 * by calling bus.resume() and/or class.resume().
26 * - If the target value is nonzero, the device is suspended by
27 * calling class.suspend() and/or bus.suspend() with event code
28 * PM_EVENT_SUSPEND.
29 *
30 * This mechanism is DEPRECATED and should only be used for testing.
26 */ 31 */
27 32
28static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf) 33static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
@@ -38,6 +43,10 @@ static ssize_t state_store(struct device * dev, struct device_attribute *attr, c
38 pm_message_t state; 43 pm_message_t state;
39 int error = -EINVAL; 44 int error = -EINVAL;
40 45
46 /* disallow incomplete suspend sequences */
47 if (dev->bus && (dev->bus->suspend_late || dev->bus->resume_early))
48 return error;
49
41 state.event = PM_EVENT_SUSPEND; 50 state.event = PM_EVENT_SUSPEND;
42 /* Older apps expected to write "3" here - confused with PCI D3 */ 51 /* Older apps expected to write "3" here - confused with PCI D3 */
43 if ((n == 1) && !strcmp(buf, "3")) 52 if ((n == 1) && !strcmp(buf, "3"))