lkml.org 
[lkml]   [2006]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] Fix Userspace interface breakage in power/state
Date
From
[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;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-02-06 21:33    [W:0.040 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site