public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: pavel@suse.cz
Subject: [PATCH] Fix Userspace interface breakage in power/state
Date: Mon, 6 Feb 2006 12:29:17 -0800	[thread overview]
Message-ID: <11392577577@kroah.com> (raw)
In-Reply-To: <20060206202830.GA5202@kroah.com>

[PATCH] Fix Userspace interface breakage in power/state

Prevent passing invalid values down to the drivers.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit 022f7b07bf2b384ece7fbd7edb90e54cd78db252
tree 7eae52ca103253babb194b8bae92c15340d82c0b
parent 68f5f996347dc2724a0dd511683643a2b6912380
author Pavel Machek <pavel@suse.cz> Sun, 22 Jan 2006 22:38:52 +0100
committer Greg Kroah-Hartman <gregkh@suse.de> Mon, 06 Feb 2006 12:17:17 -0800

 drivers/base/power/sysfs.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index f3a0c56..40d7242 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -27,22 +27,30 @@
 
 static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
 {
-	return sprintf(buf, "%u\n", dev->power.power_state.event);
+	if (dev->power.power_state.event)
+		return sprintf(buf, "2\n");
+	else
+		return sprintf(buf, "0\n");
 }
 
 static ssize_t state_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t n)
 {
 	pm_message_t state;
-	char * rest;
-	int error = 0;
+	int error = -EINVAL;
 
-	state.event = simple_strtoul(buf, &rest, 10);
-	if (*rest)
-		return -EINVAL;
-	if (state.event)
+	state.event = PM_EVENT_SUSPEND;
+	/* Older apps expected to write "3" here - confused with PCI D3 */
+	if ((n == 1) && !strcmp(buf, "3"))
 		error = dpm_runtime_suspend(dev, state);
-	else
+
+	if ((n == 1) && !strcmp(buf, "2"))
+		error = dpm_runtime_suspend(dev, state);
+
+	if ((n == 1) && !strcmp(buf, "0")) {
 		dpm_runtime_resume(dev);
+		error = 0;
+	}
+
 	return error ? error : n;
 }
 


  reply	other threads:[~2006-02-06 20:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-06 20:28 [GIT PATCH] Driver Core fixes for 2.6.16-rc2 Greg KH
2006-02-06 20:29 ` Greg KH [this message]
2006-02-06 20:29   ` [PATCH] DRM: fix up classdev interface for drm core Greg KH
2006-02-06 20:29     ` [PATCH] IB: fix up major/minor sysfs interface for IB core Greg KH
2006-02-06 20:29       ` [PATCH] SPI: spi_butterfly, restore lost deltas Greg KH
2006-02-06 20:29         ` [PATCH] kobject: don't oops on null kobject.name Greg KH
2006-02-06 20:29           ` [PATCH] kobject_add() must have a valid name in order to succeed Greg KH
2006-02-06 20:29             ` [PATCH] Fix compiler warning in driver core for CONFIG_HOTPLUG=N Greg KH
2006-02-06 20:29               ` [PATCH] drivers/base/: proper prototypes Greg KH
2006-02-06 20:29                 ` [PATCH] debugfs: trivial comment fix Greg KH
2006-02-06 20:29                   ` [PATCH] Fix uevent buffer overflow in input layer Greg KH

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=11392577577@kroah.com \
    --to=gregkh@suse.de \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.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