public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>,
	linux-pm@lists.osdl.org, linux-kernel@linux.kernel.org
Subject: Re: Userspace interface breakage in power/state
Date: Mon, 16 Jan 2006 21:24:55 +0100	[thread overview]
Message-ID: <20060116202455.GS1666@elf.ucw.cz> (raw)
In-Reply-To: <200601162122.10684.rjw@sisk.pl>

[-- Attachment #1: Type: text/plain, Size: 2173 bytes --]

On Po 16-01-06 21:22:10, Rafael J. Wysocki wrote:
> Hi,
> 
> On Monday, 16 January 2006 21:05, Pavel Machek wrote:
> > On Po 16-01-06 19:25:50, Matthew Garrett wrote:
> > > On Mon, Jan 16, 2006 at 08:20:36PM +0100, Pavel Machek wrote:
> > > 
> > > > I had patch to fix this breakage, but it was rejected. What depends on
> > > > that code?
> > > 
> > > Ubuntu's wireless disable script.
> > 
> > Can you search linux-pm archives? Search for "3" (that's '"', '3',
> > '"'). It should be somewhere. I no longer have a copy. (Probably could
> > get it from my working tree git...)
> 
> I think the appended message contains the latest version.

Thanks, thats it. Matthew, you probably want to replace "2" with "3"
below.

								Pavel

> Ok, so lets at least add value-checking to .../power file, and prevent
> userspace see changes to PM_EVENT_SUSPEND value. 2 and 0 are now
> "arbitrary cookies". I'd like to use "on" and "off", but pcmcia
> apparently depends on "2" and "0", so...
> 
> Any objections?
> 
> Signed-off-by: Pavel Machek <pavel@suse.cz>
> 								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
> @@ -27,22 +27,25 @@
>  
>  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)
> -		error = dpm_runtime_suspend(dev, state);
> -	else
> +	state.event = PM_EVENT_SUSPEND;
> +	if ((n == 1) && !strncmp(buf, "2", 1)) {
>  		dpm_runtime_resume(dev);
> +		error = 0;
> +	}
> +	if ((n == 1) && !strncmp(buf, "0", 1))
> +		error = dpm_runtime_suspend(dev, state);
> +
>  	return error ? error : n;
>  }
>  

-- 
Thanks, Sharp!

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2006-01-16 20:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-16  0:25 Userspace interface breakage in power/state Matthew Garrett
2006-01-16 19:20 ` Pavel Machek
2006-01-16 19:25   ` Matthew Garrett
2006-01-16 20:05     ` Pavel Machek
2006-01-16 20:22       ` Rafael J. Wysocki
2006-01-16 20:24         ` Pavel Machek [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-01-16  0:27 Matthew Garrett

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=20060116202455.GS1666@elf.ucw.cz \
    --to=pavel@suse.cz \
    --cc=linux-kernel@linux.kernel.org \
    --cc=linux-pm@lists.osdl.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=rjw@sisk.pl \
    /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