public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: Patrick Mochel <mochel@digitalimplant.org>
Cc: linux-pm@lists.osdl.org
Subject: Re: Runtime device power management in userspace
Date: Tue, 27 Dec 2005 22:06:27 +0100	[thread overview]
Message-ID: <20051227210627.GM1822@elf.ucw.cz> (raw)
In-Reply-To: <Pine.LNX.4.50.0512271229510.4933-100000@monsoon.he.net>

On Út 27-12-05 12:40:10, Patrick Mochel wrote:
> On Tue, 27 Dec 2005, Pavel Machek wrote:
> > On Út 27-12-05 11:29:56, Patrick Mochel wrote:
> > > But, in some cases, peple are going to care about the intermediate
> > > states, and we'll need to support them. It's simple enought to know
> > > what states a PCI device supports, so I don't understand where the
> > > complexity comes in.. ?
> >
> > Someone has to test all that... Unless we have in-tree driver that
> > wants use intermediate states, I think supporting them is bad idea.
> 
> I don't understand what your issue is; perhaps you could explain it a bit
> better. There is no additional work on the part of the core, nor any
> additional complication in supporting 4 possible power states vs
> supporting 2 vs supporting any arbitrary number that the driver and device
> implement.

Well, I can do two states today, with the patch below :-). Actually it
should work today as-is: writing 0/2 does mostly right think now.

> I did not suggest that we make the drivers support intermediate states; I
> only stated that there are some drivers and devices that can and will
> implement them, and that there are cases in which it will make sense to
> enter them from userpsace.

Ok.

> I admit I made a mistake in suggesting the interface - we wouldn't want to
> simply export all the PM states that are present in the device's config
> space. We would really only want to export the states that the driver says
> it supports. But, that could be any number of states, above and
> beyond (or

Ok.
								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!

  reply	other threads:[~2005-12-27 21:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-23 14:30 Runtime device power management in userspace Holger Macht
2005-12-23 15:12 ` Patrick Mochel
2005-12-24  0:40   ` Pavel Machek
2005-12-26 20:43     ` Patrick Mochel
2005-12-26 22:33       ` Pavel Machek
2005-12-27 18:59         ` Patrick Mochel
2005-12-27 19:22           ` Pavel Machek
2005-12-27 19:29             ` Patrick Mochel
2005-12-27 19:41               ` Pavel Machek
2005-12-27 20:40                 ` Patrick Mochel
2005-12-27 21:06                   ` Pavel Machek [this message]
2005-12-26 22:47       ` Alan Stern
2005-12-27 17:29         ` Pavel Machek
2005-12-27 17:36           ` Randy.Dunlap
2005-12-24 15:31   ` Holger Macht
2005-12-26 20:58     ` Patrick Mochel
2005-12-27 20:04       ` Pavel Machek
2005-12-27 20:54         ` Patrick Mochel
2005-12-23 15:17 ` Alan Stern
2005-12-24  0:41   ` Pavel Machek
2005-12-24  0:43   ` Pavel Machek

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=20051227210627.GM1822@elf.ucw.cz \
    --to=pavel@suse.cz \
    --cc=linux-pm@lists.osdl.org \
    --cc=mochel@digitalimplant.org \
    /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