aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/sysfs.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2006-08-30 17:12:48 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-26 00:08:37 -0400
commit047bda36150d11422b2c7bacca1df324c909c0b3 (patch)
tree3ec9e87c36f26bb945bfa8c8c4beb4c5cdfc8771 /drivers/base/power/sysfs.c
parent4fc0840006bf3df69dcf92397fdcaf85a542f939 (diff)
PM: update docs for writing .../power/state
Updates to match current code: - Make writes to the /sys/devices/.../power/state files fail cleanly if the device requires the irqs-off call variants. - Fix comments describing the /sys/devices/.../power/state file writes to match the code; the last several releases have invalidated the previous text. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/power/sysfs.c')
-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"))