power management: change /sys/power/disk display
Subsystems (2)
PATCH 1/1 power management: change /sys/power/disk display
This patch changes /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)
Documentation/power/interface.txt | 8 ++++++-- kernel/power/disk.c | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-)
kernel/power/disk.c +31 -3
@@ -322,7 +322,34 @@ static const char * const pm_disk_modes[static ssize_t disk_show (struct subsystem * subsys,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; }
@@ -363,8 +390,9 @@ static ssize_t disk_store(struct subsyst error = -EINVAL ; } -pr_debug ("PM: suspend-to-disk mode set to '%s'\n" , - pm_disk_modes[mode]); +if (!error) +pr_debug ("PM: suspend-to-disk mode set to '%s'\n" , + pm_disk_modes[mode]);mutex_unlock (&pm_mutex);return error ? error : n; }
Documentation/power/interface.txt +6 -2
@@ -34,8 +34,12 @@ for 5 seconds, resume devices, unfreeze 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'
Quoted 5 lines · Johannes Berg
This patch changes
/sys/power/diskto display all valid modes as well as the currently selected one in a fashion known from the LED subsystem.Signed-off-by Johannes Berg <[email protected]>
Looks good to me, but ... (see below)
Quoted 48 lines
---
This changes userspace API, but it is apparently not used much (we asked some userspace developers)Documentation/power/interface.txt | 8 ++++++-- kernel/power/disk.c | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-)kernel/power/disk.c +28
-1@@ -322,7 +322,34 @@ static const char * const pm_disk_modes[static ssize_t disk_show (struct subsystem * subsys,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; }@@ -363,8 +390,9 @@ static ssize_t disk_store(struct subsyst error = -EINVAL ;
kernel/power/disk.c static ssize_t disk_store(struct subsyst · line 398
Quoted 10 lines
kernel/power/disk.c +3
-2} -pr_debug ("PM: suspend-to-disk mode set to '%s'\n" , - pm_disk_modes[mode]); +if (!error) +pr_debug ("PM: suspend-to-disk mode set to '%s'\n" , + pm_disk_modes[mode]);mutex_unlock (&pm_mutex);return error ? error : n; }
.. this is an additional bugfix, right? If so, can you please separate it from this patch?
Quoted 7 lines
Documentation/power/interface.txt +0
-1@@ -34,8 +34,12 @@ for 5 seconds, resume devices, unfreeze 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
Documentation/power/interface.txt for 5 seconds, resume devices, unfreeze · line 45
Quoted 10 lines
Documentation/power/interface.txt +6
-1-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'
Greetings,
Rafael
Quoted 11 lines · Rafael J. Wysocki
kernel/power/disk.c static ssize_t disk_store(struct subsyst · line 398
Quoted 8 lines
kernel/power/disk.c +3
-2-pr_debug ("PM: suspend-to-disk mode set to '%s'\n" , - pm_disk_modes[mode]); +if (!error) +pr_debug ("PM: suspend-to-disk mode set to '%s'\n" , + pm_disk_modes[mode]);mutex_unlock (&pm_mutex);return error ? error : n; }.. this is an additional bugfix, right? If so, can you please separate it from this patch?
Huh, yes, it's separate I guess. This must have slipped in from the original patch where I had an extra file.
johannes
PATCH v2 1/1 power management: change /sys/power/disk display
In reply to Johannes BergThis patch changes /sys/power/disk to display all valid modes as well as the currently selected one in a fashion known from the LED subsystem.
--- Documentation/power/interface.txt | 8 ++++++-- kernel/power/disk.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-)
kernel/power/disk.c +28 -1
@@ -322,7 +322,34 @@ static const char * const pm_disk_modes[static ssize_t disk_show (struct subsystem * subsys,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; }
Documentation/power/interface.txt +6 -2
@@ -34,8 +34,12 @@ for 5 seconds, resume devices, unfreeze 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'
Quoted 5 lines · Johannes Berg
This patch changes
/sys/power/diskto display all valid modes as well as the currently selected one in a fashion known from the LED subsystem.Signed-off-by Johannes Berg <[email protected]>
Looks OK to me. Pavel?
Quoted 60 lines
--- Documentation/power/interface.txt | 8 ++++++-- kernel/power/disk.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-)kernel/power/disk.c +28
-1@@ -322,7 +322,34 @@ static const char * const pm_disk_modes[static ssize_t disk_show (struct subsystem * subsys,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; }Documentation/power/interface.txt +6
-2@@ -34,8 +34,12 @@ for 5 seconds, resume devices, unfreeze 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'
Hi!
Quoted 7 lines
Quoted 5 lines
This patch changes
/sys/power/diskto display all valid modes as well as the currently selected one in a fashion known from the LED subsystem.Signed-off-by Johannes Berg <[email protected]>Looks OK to me. Pavel?
ACK.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html