On Po 26-12-05 17:47:23, Alan Stern wrote: > On Mon, 26 Dec 2005, Patrick Mochel wrote: > > To that effect, the per-device power file and its semantics should go away > > completely and replaced with something that supports this new API. > > Allow me to direct your attention to this posting: > > http://lists.osdl.org/pipermail/linux-pm/2005-September/001421.html > > and the follow-on messages. They implement exactly the type of API you're > talking about. When I have some time available I will rework the patches, > with improvements as suggested by the discussions on the mailing list, and > submit them. Ok, what about this as a first step? It unbreaks the interface between kernel and user, and allows something like patches above to be taken in future, without userland changes. Pavel diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -33,15 +33,12 @@ static ssize_t state_show(struct device 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; + if ((n == 2) && !strncmp(buf, "on", min(n, 2))) error = dpm_runtime_suspend(dev, state); - else + if ((n == 7) && !strncmp(buf, "suspend", min(n, 7))) dpm_runtime_resume(dev); return error ? error : n; } -- Thanks, Sharp!