* [PATCH] power management: change /sys/power/disk display
@ 2007-04-12 0:37 Johannes Berg
2007-04-12 10:41 ` Rafael J. Wysocki
2007-04-12 10:49 ` [PATCH v2] " Johannes Berg
0 siblings, 2 replies; 14+ messages in thread
From: Johannes Berg @ 2007-04-12 0:37 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-pm
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.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
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(-)
--- wireless-dev.orig/kernel/power/disk.c 2007-04-11 18:01:08.389481358 +0200
+++ wireless-dev/kernel/power/disk.c 2007-04-11 18:01:10.109481358 +0200
@@ -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;
}
--- wireless-dev.orig/Documentation/power/interface.txt 2007-04-11 18:01:08.389481358 +0200
+++ wireless-dev/Documentation/power/interface.txt 2007-04-11 18:01:10.109481358 +0200
@@ -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'
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] power management: change /sys/power/disk display
2007-04-12 0:37 [PATCH] power management: change /sys/power/disk display Johannes Berg
@ 2007-04-12 10:41 ` Rafael J. Wysocki
2007-04-12 10:43 ` Johannes Berg
2007-04-12 10:49 ` [PATCH v2] " Johannes Berg
1 sibling, 1 reply; 14+ messages in thread
From: Rafael J. Wysocki @ 2007-04-12 10:41 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-pm, Andrew Morton
On Thursday, 12 April 2007 02:37, Johannes Berg wrote:
> 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.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Looks good to me, but ... (see below)
> ---
> 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(-)
>
> --- wireless-dev.orig/kernel/power/disk.c 2007-04-11 18:01:08.389481358 +0200
> +++ wireless-dev/kernel/power/disk.c 2007-04-11 18:01:10.109481358 +0200
> @@ -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;
> }
.. this is an additional bugfix, right? If so, can you please separate it from
this patch?
> --- wireless-dev.orig/Documentation/power/interface.txt 2007-04-11 18:01:08.389481358 +0200
> +++ wireless-dev/Documentation/power/interface.txt 2007-04-11 18:01:10.109481358 +0200
> @@ -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'
Greetings,
Rafael
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] power management: change /sys/power/disk display
2007-04-12 10:41 ` Rafael J. Wysocki
@ 2007-04-12 10:43 ` Johannes Berg
0 siblings, 0 replies; 14+ messages in thread
From: Johannes Berg @ 2007-04-12 10:43 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-pm, Andrew Morton
[-- Attachment #1.1: Type: text/plain, Size: 561 bytes --]
On Thu, 2007-04-12 at 12:41 +0200, Rafael J. Wysocki wrote:
> > - 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
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2] power management: change /sys/power/disk display
2007-04-12 0:37 [PATCH] power management: change /sys/power/disk display Johannes Berg
2007-04-12 10:41 ` Rafael J. Wysocki
@ 2007-04-12 10:49 ` Johannes Berg
2007-04-12 14:56 ` Rafael J. Wysocki
1 sibling, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2007-04-12 10:49 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-pm
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.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
Documentation/power/interface.txt | 8 ++++++--
kernel/power/disk.c | 29 ++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 3 deletions(-)
--- wireless-dev.orig/kernel/power/disk.c 2007-04-12 11:58:14.275366513 +0200
+++ wireless-dev/kernel/power/disk.c 2007-04-12 12:49:07.965366513 +0200
@@ -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;
}
--- wireless-dev.orig/Documentation/power/interface.txt 2007-04-12 11:58:14.285366513 +0200
+++ wireless-dev/Documentation/power/interface.txt 2007-04-12 11:58:15.895366513 +0200
@@ -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'
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v2] power management: change /sys/power/disk display
2007-04-12 10:49 ` [PATCH v2] " Johannes Berg
@ 2007-04-12 14:56 ` Rafael J. Wysocki
2007-04-12 20:05 ` Pavel Machek
0 siblings, 1 reply; 14+ messages in thread
From: Rafael J. Wysocki @ 2007-04-12 14:56 UTC (permalink / raw)
To: Johannes Berg, Pavel Machek; +Cc: linux-pm, Andrew Morton
On Thursday, 12 April 2007 12:49, Johannes Berg wrote:
> 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.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Looks OK to me. Pavel?
> ---
> Documentation/power/interface.txt | 8 ++++++--
> kernel/power/disk.c | 29 ++++++++++++++++++++++++++++-
> 2 files changed, 34 insertions(+), 3 deletions(-)
>
> --- wireless-dev.orig/kernel/power/disk.c 2007-04-12 11:58:14.275366513 +0200
> +++ wireless-dev/kernel/power/disk.c 2007-04-12 12:49:07.965366513 +0200
> @@ -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;
> }
>
>
> --- wireless-dev.orig/Documentation/power/interface.txt 2007-04-12 11:58:14.285366513 +0200
> +++ wireless-dev/Documentation/power/interface.txt 2007-04-12 11:58:15.895366513 +0200
> @@ -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'
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] introduce /sys/power/disk_powerdown_mode
@ 2007-03-21 9:23 Johannes Berg
2007-03-21 12:29 ` Pavel Machek
0 siblings, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2007-03-21 9:23 UTC (permalink / raw)
To: linux-pm; +Cc: Pavel Machek
This patch introduces /sys/power/disk_powerdown_mode and
deprecates /sys/power/disk. The former has the advantages
* a much more expressive name
* contains all valid modes as well as the selected one
in a fashion known from the LED subsystem.
The disk attribute is scheduled for removal, but since there
are no disadvantages in keeping we give it plenty of time.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
Documentation/feature-removal-schedule.txt | 12 +++
kernel/power/Kconfig | 13 ++++
kernel/power/disk.c | 92 ++++++++++++++++++++++++++++-
3 files changed, 114 insertions(+), 3 deletions(-)
--- linux-2.6.orig/kernel/power/disk.c 2007-03-21 08:21:18.726639252 +0100
+++ linux-2.6/kernel/power/disk.c 2007-03-21 10:16:21.802243895 +0100
@@ -307,7 +307,7 @@ static const char * const pm_disk_modes[
};
/**
- * disk - Control suspend-to-disk mode
+ * disk/disk_powerdown_mode - Control suspend-to-disk mode
*
* Suspend-to-disk can be handled in several ways. We have a few options
* for putting the system to sleep - using the platform driver (e.g. ACPI
@@ -331,6 +331,7 @@ static const char * const pm_disk_modes[
* supports it (as determined from pm_ops->pm_disk_mode).
*/
+#ifdef CONFIG_PM_DISKATTR
static ssize_t disk_show(struct subsystem * subsys, char * buf)
{
return sprintf(buf, "%s\n", pm_disk_modes[pm_disk_mode]);
@@ -374,13 +375,95 @@ 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;
}
power_attr(disk);
+#endif
+
+static ssize_t disk_powerdown_mode_show(struct subsystem *subsys, char *buf)
+{
+ 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;
+}
+
+
+static ssize_t disk_powerdown_mode_store(struct subsystem *s,
+ const char *buf, size_t n)
+{
+ int error = 0;
+ int i;
+ int len;
+ char *p;
+ suspend_disk_method_t mode = 0;
+
+ p = memchr(buf, '\n', n);
+ len = p ? p - buf : n;
+
+ mutex_lock(&pm_mutex);
+ for (i = PM_DISK_PLATFORM; i < PM_DISK_MAX; i++) {
+ if (!strncmp(buf, pm_disk_modes[i], len)) {
+ mode = i;
+ break;
+ }
+ }
+ if (mode) {
+ switch (mode) {
+ case PM_DISK_SHUTDOWN:
+ case PM_DISK_REBOOT:
+ case PM_DISK_TEST:
+ case PM_DISK_TESTPROC:
+ pm_disk_mode = mode;
+ break;
+ default:
+ if (pm_ops && pm_ops->enter &&
+ (mode == pm_ops->pm_disk_mode))
+ pm_disk_mode = mode;
+ else
+ error = -EINVAL;
+ }
+ } else {
+ error = -EINVAL;
+ }
+
+ 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;
+}
+
+power_attr(disk_powerdown_mode);
static ssize_t resume_show(struct subsystem * subsys, char *buf)
{
@@ -434,7 +517,10 @@ static ssize_t image_size_store(struct s
power_attr(image_size);
static struct attribute * g[] = {
+#ifdef CONFIG_PM_DISKATTR
&disk_attr.attr,
+#endif
+ &disk_powerdown_mode_attr.attr,
&resume_attr.attr,
&image_size_attr.attr,
NULL,
--- linux-2.6.orig/kernel/power/Kconfig 2007-03-21 08:27:18.496639252 +0100
+++ linux-2.6/kernel/power/Kconfig 2007-03-21 10:17:42.562243895 +0100
@@ -19,6 +19,19 @@ config PM
will issue the hlt instruction if nothing is to be done, thereby
sending the processor to sleep and saving power.
+config PM_DISKATTR
+ bool "disk attribute in /sys/power/"
+ depends on PM
+ default y
+ ---help---
+ The "disk" attribute in /sys/power/ is being deprecated in favour
+ of the "disk_powerdown_mode" attribute because the former does not
+ let userspace see which modes are possible and the name is not
+ very expressive.
+
+ Deselect this option to turn off the deprecated disk attribute.
+ If unsure, leave this option enabled.
+
config PM_LEGACY
bool "Legacy Power Management API (DEPRECATED)"
depends on PM
--- linux-2.6.orig/Documentation/feature-removal-schedule.txt 2007-03-21 10:11:52.452243895 +0100
+++ linux-2.6/Documentation/feature-removal-schedule.txt 2007-03-21 10:18:37.832243895 +0100
@@ -334,3 +334,15 @@ Why: powermac supports proper generic pm
Who: Johannes Berg <johannes@sipsolutions.net>
---------------------------
+
+What: /sys/power/disk
+When: Set PM_DISKATTR default n in 2.6.24, remove in 2.6.26
+Files: kernel/power/disk.c kernel/power/Kconfig
+Why: /sys/power/disk is not a very expressive name for what it
+ really is: /sys/power/disk_powerdown_mode. Having introduced
+ the latter which also has the advantage that it contains all
+ valid modes as well as the currently selected mode,
+ /sys/power/disk becomes useless.
+Who: Johannes Berg <johannes@sipsolutions.net>
+
+---------------------------
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] introduce /sys/power/disk_powerdown_mode
2007-03-21 9:23 [PATCH] introduce /sys/power/disk_powerdown_mode Johannes Berg
@ 2007-03-21 12:29 ` Pavel Machek
2007-03-21 12:32 ` Johannes Berg
0 siblings, 1 reply; 14+ messages in thread
From: Pavel Machek @ 2007-03-21 12:29 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-pm
Hi!
> This patch introduces /sys/power/disk_powerdown_mode and
> deprecates /sys/power/disk. The former has the advantages
> * a much more expressive name
> * contains all valid modes as well as the selected one
> in a fashion known from the LED subsystem.
>
> The disk attribute is scheduled for removal, but since there
> are no disadvantages in keeping we give it plenty of time.
Does it really need to be this complex? Maybe we can disply change
/sys/power/disk format? Is the change required at all?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] introduce /sys/power/disk_powerdown_mode
2007-03-21 12:29 ` Pavel Machek
@ 2007-03-21 12:32 ` Johannes Berg
2007-03-21 13:11 ` Pavel Machek
0 siblings, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2007-03-21 12:32 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 439 bytes --]
On Wed, 2007-03-21 at 13:29 +0100, Pavel Machek wrote:
> Does it really need to be this complex? Maybe we can disply change
> /sys/power/disk format? Is the change required at all?
Dunno. Does anything ever read it? Maybe the whole change isn't
necessary since this thing exists only as a hack for ACPI anyway, but if
anybody starts using it with an actual choice being able to see the
choices would imho be useful.
johannes
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] introduce /sys/power/disk_powerdown_mode
2007-03-21 12:32 ` Johannes Berg
@ 2007-03-21 13:11 ` Pavel Machek
2007-03-21 13:12 ` Johannes Berg
0 siblings, 1 reply; 14+ messages in thread
From: Pavel Machek @ 2007-03-21 13:11 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-pm
On Wed 2007-03-21 13:32:55, Johannes Berg wrote:
> On Wed, 2007-03-21 at 13:29 +0100, Pavel Machek wrote:
>
> > Does it really need to be this complex? Maybe we can disply change
> > /sys/power/disk format? Is the change required at all?
>
> Dunno. Does anything ever read it? Maybe the whole change isn't
> necessary since this thing exists only as a hack for ACPI anyway, but if
> anybody starts using it with an actual choice being able to see the
> choices would imho be useful.
I believe we can just show the list of choices, without changing the
name.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] introduce /sys/power/disk_powerdown_mode
2007-03-21 13:11 ` Pavel Machek
@ 2007-03-21 13:12 ` Johannes Berg
2007-03-22 14:34 ` [PATCH] power management: change /sys/power/disk display Johannes Berg
0 siblings, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2007-03-21 13:12 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 829 bytes --]
On Wed, 2007-03-21 at 14:11 +0100, Pavel Machek wrote:
> On Wed 2007-03-21 13:32:55, Johannes Berg wrote:
> > On Wed, 2007-03-21 at 13:29 +0100, Pavel Machek wrote:
> >
> > > Does it really need to be this complex? Maybe we can disply change
> > > /sys/power/disk format? Is the change required at all?
> >
> > Dunno. Does anything ever read it? Maybe the whole change isn't
> > necessary since this thing exists only as a hack for ACPI anyway, but if
> > anybody starts using it with an actual choice being able to see the
> > choices would imho be useful.
>
> I believe we can just show the list of choices, without changing the
> name.
Ok, I can simplify the patch down to that, the only thing about that is
that it breaks userspace ABI. Dunno how people react to that with
suspend though :)
johannes
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] power management: change /sys/power/disk display
2007-03-21 13:12 ` Johannes Berg
@ 2007-03-22 14:34 ` Johannes Berg
2007-03-22 21:45 ` Rafael J. Wysocki
2007-03-23 0:05 ` Pavel Machek
0 siblings, 2 replies; 14+ messages in thread
From: Johannes Berg @ 2007-03-22 14:34 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-pm
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.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
This patch is the simplified version that just changes the attribute
instead of introducing a new on. It also contains the relevant updates
to the documentation.
Good to push for .22?
Documentation/power/interface.txt | 8 ++++++--
kernel/power/disk.c | 34 +++++++++++++++++++++++++++++++---
2 files changed, 37 insertions(+), 5 deletions(-)
--- linux-2.6.orig/kernel/power/disk.c 2007-03-22 13:56:20.184654656 +0100
+++ linux-2.6/kernel/power/disk.c 2007-03-22 14:00:18.754654656 +0100
@@ -333,7 +333,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;
}
@@ -374,8 +401,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;
}
--- linux-2.6.orig/Documentation/power/interface.txt 2007-03-22 14:01:09.684654656 +0100
+++ linux-2.6/Documentation/power/interface.txt 2007-03-22 14:02:22.984654656 +0100
@@ -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'
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH] power management: change /sys/power/disk display
2007-03-22 14:34 ` [PATCH] power management: change /sys/power/disk display Johannes Berg
@ 2007-03-22 21:45 ` Rafael J. Wysocki
2007-03-23 0:05 ` Pavel Machek
1 sibling, 0 replies; 14+ messages in thread
From: Rafael J. Wysocki @ 2007-03-22 21:45 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-pm, Pavel Machek
On Thursday, 22 March 2007 15:34, Johannes Berg wrote:
> 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.
>
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
No objections from me.
> ---
> This patch is the simplified version that just changes the attribute
> instead of introducing a new on. It also contains the relevant updates
> to the documentation.
>
> Good to push for .22?
Well, I think it can go to -mm for now (if Pavel agrees with it). Later we'll
decide whether it should go into .22 or .23.
Greetings,
Rafael
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] power management: change /sys/power/disk display
2007-03-22 14:34 ` [PATCH] power management: change /sys/power/disk display Johannes Berg
2007-03-22 21:45 ` Rafael J. Wysocki
@ 2007-03-23 0:05 ` Pavel Machek
2007-03-23 13:48 ` Johannes Berg
1 sibling, 1 reply; 14+ messages in thread
From: Pavel Machek @ 2007-03-23 0:05 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-pm
On Thu 2007-03-22 15:34:11, Johannes Berg wrote:
> 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.
looks ok to me. It changes userland interface, but I believe noone
uses this particular detail.
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
ack.
> ---
> This patch is the simplified version that just changes the attribute
> instead of introducing a new on. It also contains the relevant updates
> to the documentation.
>
> Good to push for .22?
Actually, this may even be .23 material.
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] power management: change /sys/power/disk display
2007-03-23 0:05 ` Pavel Machek
@ 2007-03-23 13:48 ` Johannes Berg
2007-03-23 23:46 ` Pavel Machek
0 siblings, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2007-03-23 13:48 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 214 bytes --]
On Fri, 2007-03-23 at 01:05 +0100, Pavel Machek wrote:
> Actually, this may even be .23 material.
Fine with me, I have no particular need for this. Just don't want to
track the patch forever ;)
johannes
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] power management: change /sys/power/disk display
2007-03-23 13:48 ` Johannes Berg
@ 2007-03-23 23:46 ` Pavel Machek
2007-03-23 23:53 ` Johannes Berg
0 siblings, 1 reply; 14+ messages in thread
From: Pavel Machek @ 2007-03-23 23:46 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-pm
On Fri 2007-03-23 14:48:47, Johannes Berg wrote:
> On Fri, 2007-03-23 at 01:05 +0100, Pavel Machek wrote:
>
> > Actually, this may even be .23 material.
>
> Fine with me, I have no particular need for this. Just don't want to
> track the patch forever ;)
Send it to akpm, he's good at tracking :).
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] power management: change /sys/power/disk display
2007-03-23 23:46 ` Pavel Machek
@ 2007-03-23 23:53 ` Johannes Berg
2007-03-24 0:14 ` Pavel Machek
0 siblings, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2007-03-23 23:53 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 179 bytes --]
On Sat, 2007-03-24 at 00:46 +0100, Pavel Machek wrote:
> Send it to akpm, he's good at tracking :).
Heh. But then I'd have to know what kernel we want it in ;)
johannes
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] power management: change /sys/power/disk display
2007-03-23 23:53 ` Johannes Berg
@ 2007-03-24 0:14 ` Pavel Machek
2007-03-24 0:16 ` Johannes Berg
0 siblings, 1 reply; 14+ messages in thread
From: Pavel Machek @ 2007-03-24 0:14 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-pm
On Sat 2007-03-24 00:53:41, Johannes Berg wrote:
> On Sat, 2007-03-24 at 00:46 +0100, Pavel Machek wrote:
>
> > Send it to akpm, he's good at tracking :).
>
> Heh. But then I'd have to know what kernel we want it in ;)
No, just send him patch, and let the decision when to push it on me
and him.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] power management: change /sys/power/disk display
2007-03-24 0:14 ` Pavel Machek
@ 2007-03-24 0:16 ` Johannes Berg
0 siblings, 0 replies; 14+ messages in thread
From: Johannes Berg @ 2007-03-24 0:16 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-pm
[-- Attachment #1.1: Type: text/plain, Size: 442 bytes --]
On Sat, 2007-03-24 at 01:14 +0100, Pavel Machek wrote:
> On Sat 2007-03-24 00:53:41, Johannes Berg wrote:
> > On Sat, 2007-03-24 at 00:46 +0100, Pavel Machek wrote:
> >
> > > Send it to akpm, he's good at tracking :).
> >
> > Heh. But then I'd have to know what kernel we want it in ;)
>
> No, just send him patch, and let the decision when to push it on me
> and him.
Ok, that works too, will do that later then.
johannes
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2007-04-12 20:05 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-12 0:37 [PATCH] power management: change /sys/power/disk display Johannes Berg
2007-04-12 10:41 ` Rafael J. Wysocki
2007-04-12 10:43 ` Johannes Berg
2007-04-12 10:49 ` [PATCH v2] " Johannes Berg
2007-04-12 14:56 ` Rafael J. Wysocki
2007-04-12 20:05 ` Pavel Machek
-- strict thread matches above, loose matches on Subject: below --
2007-03-21 9:23 [PATCH] introduce /sys/power/disk_powerdown_mode Johannes Berg
2007-03-21 12:29 ` Pavel Machek
2007-03-21 12:32 ` Johannes Berg
2007-03-21 13:11 ` Pavel Machek
2007-03-21 13:12 ` Johannes Berg
2007-03-22 14:34 ` [PATCH] power management: change /sys/power/disk display Johannes Berg
2007-03-22 21:45 ` Rafael J. Wysocki
2007-03-23 0:05 ` Pavel Machek
2007-03-23 13:48 ` Johannes Berg
2007-03-23 23:46 ` Pavel Machek
2007-03-23 23:53 ` Johannes Berg
2007-03-24 0:14 ` Pavel Machek
2007-03-24 0:16 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox