public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Pavel Machek <pavel@ucw.cz>
Cc: linux-pm <linux-pm@lists.osdl.org>
Subject: [PATCH] power management: change /sys/power/disk display
Date: Thu, 22 Mar 2007 15:34:11 +0100	[thread overview]
Message-ID: <1174574051.3588.5.camel@johannes.berg> (raw)
In-Reply-To: <1174482773.4230.19.camel@johannes.berg>

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'

  parent reply	other threads:[~2007-03-22 14:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-21  9:23 [PATCH] introduce /sys/power/disk_powerdown_mode Johannes Berg
2007-03-21 12:25 ` Rafael J. Wysocki
2007-03-21 12:25   ` 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-21 13:17         ` Pavel Machek
2007-03-21 14:01           ` Rafael J. Wysocki
2007-03-21 22:08             ` Pavel Machek
2007-03-22 13:13               ` [linux-pm] " Stefan Seyfried
2007-03-22 14:34         ` Johannes Berg [this message]
2007-03-22 21:45           ` [PATCH] power management: change /sys/power/disk display 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
  -- strict thread matches above, loose matches on Subject: below --
2007-04-12  0:37 Johannes Berg
2007-04-12 10:41 ` Rafael J. Wysocki
2007-04-12 10:43   ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1174574051.3588.5.camel@johannes.berg \
    --to=johannes@sipsolutions.net \
    --cc=linux-pm@lists.osdl.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox