summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mochel <mochel@osdl.org>2003-08-13 22:41:10 -0700
committerPatrick Mochel <mochel@osdl.org>2003-08-13 22:41:10 -0700
commit0b081c819fa9419fb6e027772f08dccac1f8ea8a (patch)
treeea86d320be501ed121afa65270337accc1a46436
parent47149728061b93f44f39ae5e682c8d306c3469e7 (diff)
[driver model] Remove 'power' file in favor of 'power' directory.
- Only present when CONFIG_PM=y. - Contains 'state' file for controlling power state with new PM infrastructure.
-rw-r--r--drivers/base/interface.c70
-rw-r--r--drivers/base/power/sysfs.c24
2 files changed, 21 insertions, 73 deletions
diff --git a/drivers/base/interface.c b/drivers/base/interface.c
index 8de53d218226..f5da0418284d 100644
--- a/drivers/base/interface.c
+++ b/drivers/base/interface.c
@@ -21,75 +21,6 @@ static ssize_t device_read_name(struct device * dev, char * buf)
static DEVICE_ATTR(name,S_IRUGO,device_read_name,NULL);
-static ssize_t
-device_read_power(struct device * dev, char * page)
-{
- return sprintf(page,"%d\n",dev->power_state);
-}
-
-static ssize_t
-device_write_power(struct device * dev, const char * buf, size_t count)
-{
- char str_command[20];
- char str_level[20];
- int num_args;
- u32 state;
- u32 int_level;
- int error = 0;
-
- if (!dev->driver)
- goto done;
-
- num_args = sscanf(buf,"%10s %10s %u",str_command,str_level,&state);
-
- error = -EINVAL;
-
- if (!num_args)
- goto done;
-
- if (!strnicmp(str_command,"suspend",7)) {
- if (num_args != 3)
- goto done;
- if (!strnicmp(str_level,"notify",6))
- int_level = SUSPEND_NOTIFY;
- else if (!strnicmp(str_level,"save",4))
- int_level = SUSPEND_SAVE_STATE;
- else if (!strnicmp(str_level,"disable",7))
- int_level = SUSPEND_DISABLE;
- else if (!strnicmp(str_level,"powerdown",8))
- int_level = SUSPEND_POWER_DOWN;
- else
- goto done;
-
- if (dev->driver->suspend)
- error = dev->driver->suspend(dev,state,int_level);
- else
- error = 0;
- } else if (!strnicmp(str_command,"resume",6)) {
- if (num_args != 2)
- goto done;
-
- if (!strnicmp(str_level,"poweron",7))
- int_level = RESUME_POWER_ON;
- else if (!strnicmp(str_level,"restore",7))
- int_level = RESUME_RESTORE_STATE;
- else if (!strnicmp(str_level,"enable",6))
- int_level = RESUME_ENABLE;
- else
- goto done;
-
- if (dev->driver->resume)
- error = dev->driver->resume(dev,int_level);
- else
- error = 0;
- }
- done:
- return error < 0 ? error : count;
-}
-
-static DEVICE_ATTR(power,S_IWUSR | S_IRUGO,
- device_read_power,device_write_power);
-
/**
* detach_state - control the default power state for the device.
*
@@ -123,7 +54,6 @@ static DEVICE_ATTR(detach_state,0644,detach_show,detach_store);
struct attribute * dev_default_attrs[] = {
&dev_attr_name.attr,
- &dev_attr_power.attr,
&dev_attr_detach_state.attr,
NULL,
};
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 578b527a6940..0fddee58893f 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -5,6 +5,25 @@
#include <linux/device.h>
#include "power.h"
+
+/**
+ * state - Control current power state of device
+ *
+ * show() returns the current power state of the device. '0' indicates
+ * the device is on. Other values (1-3) indicate the device is in a low
+ * power state.
+ *
+ * store() sets the current power state, which is an integer value
+ * between 0-3. If the device is on ('0'), and the value written is
+ * greater than 0, then the device is placed directly into the low-power
+ * state (via its driver's ->suspend() method).
+ * If the device is currently in a low-power state, and the value is 0,
+ * the device is powered back on (via the ->resume() method).
+ * If the device is in a low-power state, and a different low-power state
+ * is requested, the device is first resumed, then suspended into the new
+ * low-power state.
+ */
+
static ssize_t state_show(struct device * dev, char * buf)
{
return sprintf(buf,"%u\n",dev->power.power_state);
@@ -26,8 +45,7 @@ static ssize_t state_store(struct device * dev, const char * buf, size_t n)
return error ? error : n;
}
-DEVICE_ATTR(state,0644,state_show,state_store);
-
+static DEVICE_ATTR(state,0644,state_show,state_store);
static struct attribute * power_attrs[] = {
@@ -35,7 +53,7 @@ static struct attribute * power_attrs[] = {
NULL,
};
static struct attribute_group pm_attr_group = {
- .name = "pm",
+ .name = "power",
.attrs = power_attrs,
};