]> git.hungrycats.org Git - linux/commitdiff
[power mgmt] Make system state enums match device state values.
authorPatrick Mochel <mochel@digitalimplant.org>
Fri, 24 Sep 2004 11:51:10 +0000 (04:51 -0700)
committerPatrick Mochel <mochel@digitalimplant.org>
Fri, 24 Sep 2004 11:51:10 +0000 (04:51 -0700)
Changes the PM_SUSPEND_MEM (and PM_SUSPEND_DISK) enum values so that
they make sense as PCI device power states.

(a) Fixes bugs whereby PCI drivers are being given bogus values.
    This should resolve OSDL bugid 2886 without changing the PCI
    API (its PM calls still act as on 2.4 kernels).

(b) Doesn't change the awkward assumption in the 2.6 PMcore that
    the /sys/bus/*/devices/power/state, /proc/acpi/sleep,
    dev->power.power_state, and dev->detach_state files share
    the same numeric codes ... even for busses very unlike PCI,
    or systems with several "on" policies as well as STD and STR,
    or with device-PM transtions with no system-wide equivalent.

Really we need to move away from "u32" codes that are easily confused
with each other, towards typed values (probably struct pointers), but
that's a long-term change and we need the PCI issue fixed sooner.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
include/linux/pm.h
kernel/power/main.c

index d54bc441daff3c5635ac46f88273c7a6e3658b3e..7bfd2d43963e09989fa2a692e556e1c04343546b 100644 (file)
@@ -194,11 +194,12 @@ extern void (*pm_idle)(void);
 extern void (*pm_power_off)(void);
 
 enum {
-       PM_SUSPEND_ON,
-       PM_SUSPEND_STANDBY,
-       PM_SUSPEND_MEM,
-       PM_SUSPEND_DISK,
-       PM_SUSPEND_MAX,
+       PM_SUSPEND_ON = 0,
+       PM_SUSPEND_STANDBY = 1,
+       /* NOTE: PM_SUSPEND_MEM == PCI_D3hot */
+       PM_SUSPEND_MEM = 3,
+       PM_SUSPEND_DISK = 4,
+       PM_SUSPEND_MAX = 5,
 };
 
 enum {
index 6b5c59cc26ba47c8f1e64bc2adc0bc5e8dbb69b7..2f08a432f0d51c6705dd503d80ad7d23f2aef80a 100644 (file)
@@ -230,8 +230,8 @@ static ssize_t state_store(struct subsystem * subsys, const char * buf, size_t n
        p = memchr(buf, '\n', n);
        len = p ? p - buf : n;
 
-       for (s = &pm_states[state]; *s; s++, state++) {
-               if (!strncmp(buf, *s, len))
+       for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
+               if (*s && !strncmp(buf, *s, len))
                        break;
        }
        if (*s)