Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f0ced9b229cfbc76b5db9837b4b256b602d56610
Commit:     f0ced9b229cfbc76b5db9837b4b256b602d56610
Parent:     ab3bfca7abf3fd0fe41d26d839610a787aa7e587
Author:     Johannes Berg <[EMAIL PROTECTED]>
AuthorDate: Sun May 6 14:50:50 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon May 7 12:12:59 2007 -0700

    power management: change /sys/power/disk display
    
    Change /sys/power/disk to display all valid modes as well as the currently
    selected one in a fashion known from the LED subsystem.
    
    This changes userspace API, but it is apparently not used much (we asked
    some userspace developers)
    
    Signed-off-by: Johannes Berg <[EMAIL PROTECTED]>
    Acked-by: "Rafael J. Wysocki" <[EMAIL PROTECTED]>
    Acked-by: Pavel Machek <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 Documentation/power/interface.txt |    8 ++++++--
 kernel/power/disk.c               |   29 ++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/Documentation/power/interface.txt 
b/Documentation/power/interface.txt
index 8c5b41b..fd5192a 100644
--- a/Documentation/power/interface.txt
+++ b/Documentation/power/interface.txt
@@ -34,8 +34,12 @@ for 5 seconds, resume devices, unfreeze tasks and enable 
nonboot CPUs.  Then,
 we are able to look in the log messages and work out, for example, which code
 is being slow and which device drivers are misbehaving.
 
-Reading from this file will display what the mode is currently set
-to. Writing to this file will accept one of
+Reading from this file will display all supported modes and the currently
+selected one in brackets, for example
+
+       [shutdown] reboot test testproc
+
+Writing to this file will accept one of
 
        'platform' (only if the platform supports it)
        'shutdown'
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index e518379..0633137 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -350,7 +350,34 @@ static const char * const pm_disk_modes[] = {
 
 static ssize_t disk_show(struct kset *kset, char *buf)
 {
-       return sprintf(buf, "%s\n", pm_disk_modes[pm_disk_mode]);
+       int i;
+       char *start = buf;
+
+       for (i = PM_DISK_PLATFORM; i < PM_DISK_MAX; i++) {
+               if (!pm_disk_modes[i])
+                       continue;
+               switch (i) {
+               case PM_DISK_SHUTDOWN:
+               case PM_DISK_REBOOT:
+               case PM_DISK_TEST:
+               case PM_DISK_TESTPROC:
+                       break;
+               default:
+                       if (pm_ops && pm_ops->enter &&
+                           (i == pm_ops->pm_disk_mode))
+                               break;
+                       /* not a valid mode, continue with loop */
+                       continue;
+               }
+               if (i == pm_disk_mode)
+                       buf += sprintf(buf, "[%s]", pm_disk_modes[i]);
+               else
+                       buf += sprintf(buf, "%s", pm_disk_modes[i]);
+               if (i+1 != PM_DISK_MAX)
+                       buf += sprintf(buf, " ");
+       }
+       buf += sprintf(buf, "\n");
+       return buf-start;
 }
 
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to