public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Patrick Mochel <mochel@digitalimplant.org>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux-pm mailing list <linux-pm@lists.osdl.org>,
	kernel list <linux-kernel@vger.kernel.org>,
	Dominik Brodowski <linux@dominikbrodowski.net>
Subject: Re: [patch] pm: fix runtime powermanagement's /sys interface
Date: Fri, 6 Jan 2006 01:12:52 +0100	[thread overview]
Message-ID: <20060106001252.GE3339@elf.ucw.cz> (raw)
In-Reply-To: <Pine.LNX.4.50.0601051602560.10428-100000@monsoon.he.net>

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

On Čt 05-01-06 16:04:07, Patrick Mochel wrote:
> 
> On Fri, 6 Jan 2006, Pavel Machek wrote:
> 
> > On Pá 06-01-06 00:46:29, Dominik Brodowski wrote:
> > > On Fri, Jan 06, 2006 at 12:08:49AM +0100, Pavel Machek wrote:
> > > > 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?
> > >
> > > Sorry, but yes -- the same as before, minus the PCMCIA breakage.
> >
> > I don't understand at this point.
> >
> > Current code takes value from user, and passes it down to driver,
> > without any checking. If user writes 666 into the file, it will
> > happily pass down 666 to the driver. Driver does not expect 666 in
> > pm_message_t.event. It may oops, BUG_ON() or anything like that.
> >
> > Shall I change
> >
> > #define PM_EVENT_SUSPEND 2
> >
> > to
> >
> > #define PM_EVENT_SUSPEND 1324
> >
> > to get my point across? This is kernel-specific value, it should not
> > be exported to userland.
> 
> A better point, and one that would actually be useful, would be to remove
> the file altogether. Let Dominik export a power file, with complete
> control over the values, for each pcmcia device. Then you never have to
> worry about breaking PCMCIA again.

Fine with me.

[except that now you we went from supporting 2 runtime device states
to supporting just 1... I don't think this is much of progress...]

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
@@ -6,49 +6,6 @@
 #include <linux/string.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, struct device_attribute *attr, char * buf)
-{
-	return sprintf(buf, "%u\n", dev->power.power_state.event);
-}
-
-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;
-
-	state.event = simple_strtoul(buf, &rest, 10);
-	if (*rest)
-		return -EINVAL;
-	if (state.event)
-		error = dpm_runtime_suspend(dev, state);
-	else
-		dpm_runtime_resume(dev);
-	return error ? error : n;
-}
-
-static DEVICE_ATTR(state, 0644, state_show, state_store);
-
-
 /*
  *	wakeup - Report/change current wakeup option for device
  *
@@ -122,7 +79,6 @@ static DEVICE_ATTR(wakeup, 0644, wake_sh
 
 
 static struct attribute * power_attrs[] = {
-	&dev_attr_state.attr,
 	&dev_attr_wakeup.attr,
 	NULL,
 };

-- 
Thanks, Sharp!

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



  reply	other threads:[~2006-01-06  0:12 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-27 21:34 [patch] pm: fix runtime powermanagement's /sys interface Pavel Machek
2005-12-27 21:55 ` Dmitry Torokhov
2005-12-27 22:05   ` Pavel Machek
2005-12-28  4:22     ` Patrick Mochel
2006-01-04 21:34       ` [linux-pm] " Pavel Machek
2006-01-04 22:06         ` Alan Stern
2006-01-04 22:16           ` [linux-pm] " Pavel Machek
2006-01-05 21:43           ` Patrick Mochel
2006-01-05 22:06             ` [linux-pm] " Alan Stern
2006-01-05 22:28               ` Pavel Machek
2006-01-05 21:42         ` [linux-pm] " Patrick Mochel
2006-01-05 21:55           ` Pavel Machek
2006-01-05 22:13             ` [linux-pm] " Dominik Brodowski
2006-01-05 22:23               ` Pavel Machek
2006-01-05 22:27                 ` Dominik Brodowski
2006-01-05 22:59                   ` Pavel Machek
2006-01-05 23:08                   ` Pavel Machek
2006-01-05 23:46                     ` [linux-pm] " Dominik Brodowski
2006-01-05 23:58                       ` Pavel Machek
2006-01-06  0:04                         ` Patrick Mochel
2006-01-06  0:12                           ` Pavel Machek [this message]
2006-01-06  1:37                             ` Patrick Mochel
2006-01-06  8:59                               ` Pavel Machek
2006-01-07  5:47                                 ` Adam Belay
2006-01-06  9:00                               ` Pavel Machek
2006-01-06 15:00                               ` Dominik Brodowski
2006-01-07  5:58                                 ` Adam Belay
2006-01-06 15:42                               ` Alan Stern
2006-01-07  0:08                                 ` Pavel Machek
2006-01-07  3:19                                   ` Alan Stern
2006-01-07  7:58                                   ` Adam Belay
2006-01-07 10:20                                     ` Pavel Machek
2006-01-07 13:06                                       ` Adam Belay
2006-01-06  4:17                                         ` Pavel Machek
2006-01-07  7:41                                 ` [linux-pm] " Adam Belay
2006-01-07 15:24                                   ` Alan Stern
2006-01-06  1:10                           ` Dominik Brodowski
2006-01-06  8:53                             ` Pavel Machek
2006-01-06  0:38                   ` Greg KH
2006-01-06 15:03                     ` Dominik Brodowski
2006-01-06 16:25                       ` Kay Sievers
2006-01-09 20:10                         ` [linux-pm] " Dominik Brodowski
2006-01-05 22:15             ` Patrick Mochel
2006-01-05 22:44               ` Pavel Machek
2006-01-05 23:54                 ` Patrick Mochel
2006-01-06  0:07                   ` [linux-pm] " Pavel Machek
2006-01-06 14:34             ` Tom Marshall
2006-01-06 16:20               ` Pavel Machek
2006-01-07  8:36         ` Adam Belay
2006-01-07 10:25           ` Pavel Machek
2006-01-07 12:45             ` Adam Belay
2006-01-06  4:24               ` Pavel Machek
2006-01-13 20:00                 ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2006-01-05 15:16 Scott E. Preece
2006-01-05 22:21 Preece Scott-PREECE
2006-01-05 22:45 ` Pavel Machek
2006-01-06  0:02 ` Patrick Mochel
2006-01-05 22:55 Preece Scott-PREECE
2006-01-05 23:05 ` Pavel Machek
2006-01-06  0:31 Scott E. Preece

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=20060106001252.GE3339@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.osdl.org \
    --cc=linux@dominikbrodowski.net \
    --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