public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM: make runtime_status attribute not debug-only
@ 2010-07-02 16:51 Alan Stern
  2010-07-02 18:29 ` Dominik Brodowski
  2010-07-02 19:14 ` Rafael J. Wysocki
  0 siblings, 2 replies; 7+ messages in thread
From: Alan Stern @ 2010-07-02 16:51 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux-pm mailing list, Dominik Brodowski

This patch (as1404) makes the runtime_status sysfs attribute available
even in the absence of CONFIG_PM_ADVANCED_DEBUG, and it changes the
routine to display "unknown" when runtime PM is disabled for a device.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---

Maybe "unsupported" would be a little better than "unknown".  What do 
you think?



Index: usb-2.6/drivers/base/power/sysfs.c
===================================================================
--- usb-2.6.orig/drivers/base/power/sysfs.c
+++ usb-2.6/drivers/base/power/sysfs.c
@@ -108,6 +108,38 @@ static ssize_t control_store(struct devi
 }
 
 static DEVICE_ATTR(control, 0644, control_show, control_store);
+
+static ssize_t rtpm_status_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	const char *p;
+
+	if (dev->power.runtime_error) {
+		p = "error\n";
+	} else if (dev->power.disable_depth) {
+		p = "unknown\n";
+	} else {
+		switch (dev->power.runtime_status) {
+		case RPM_SUSPENDED:
+			p = "suspended\n";
+			break;
+		case RPM_SUSPENDING:
+			p = "suspending\n";
+			break;
+		case RPM_RESUMING:
+			p = "resuming\n";
+			break;
+		case RPM_ACTIVE:
+			p = "active\n";
+			break;
+		default:
+			return -EIO;
+		}
+	}
+	return sprintf(buf, p);
+}
+
+static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
 #endif
 
 static ssize_t
@@ -172,27 +204,8 @@ static ssize_t rtpm_enabled_show(struct 
 	return sprintf(buf, "enabled\n");
 }
 
-static ssize_t rtpm_status_show(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	if (dev->power.runtime_error)
-		return sprintf(buf, "error\n");
-	switch (dev->power.runtime_status) {
-	case RPM_SUSPENDED:
-		return sprintf(buf, "suspended\n");
-	case RPM_SUSPENDING:
-		return sprintf(buf, "suspending\n");
-	case RPM_RESUMING:
-		return sprintf(buf, "resuming\n");
-	case RPM_ACTIVE:
-		return sprintf(buf, "active\n");
-	}
-	return -EIO;
-}
-
 static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
 static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
-static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
 static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
 
 #endif
@@ -228,6 +241,7 @@ static DEVICE_ATTR(async, 0644, async_sh
 static struct attribute * power_attrs[] = {
 #ifdef CONFIG_PM_RUNTIME
 	&dev_attr_control.attr,
+	&dev_attr_runtime_status.attr,
 #endif
 	&dev_attr_wakeup.attr,
 #ifdef CONFIG_PM_ADVANCED_DEBUG
@@ -235,7 +249,6 @@ static struct attribute * power_attrs[] 
 #ifdef CONFIG_PM_RUNTIME
 	&dev_attr_runtime_usage.attr,
 	&dev_attr_runtime_active_kids.attr,
-	&dev_attr_runtime_status.attr,
 	&dev_attr_runtime_enabled.attr,
 #endif
 #endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PM: make runtime_status attribute not debug-only
  2010-07-02 16:51 [PATCH] PM: make runtime_status attribute not debug-only Alan Stern
@ 2010-07-02 18:29 ` Dominik Brodowski
  2010-07-02 19:14 ` Rafael J. Wysocki
  1 sibling, 0 replies; 7+ messages in thread
From: Dominik Brodowski @ 2010-07-02 18:29 UTC (permalink / raw)
  To: Alan Stern; +Cc: Linux-pm mailing list


"unsupported" sounds even better ;)

On Fri, Jul 02, 2010 at 12:51:41PM -0400, Alan Stern wrote:
> This patch (as1404) makes the runtime_status sysfs attribute available
> even in the absence of CONFIG_PM_ADVANCED_DEBUG, and it changes the
> routine to display "unknown" when runtime PM is disabled for a device.
> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

Acked-by: Dominik Brodowski <linux@dominikbrodowski.net>

Thanks,
	Dominik

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PM: make runtime_status attribute not debug-only
  2010-07-02 16:51 [PATCH] PM: make runtime_status attribute not debug-only Alan Stern
  2010-07-02 18:29 ` Dominik Brodowski
@ 2010-07-02 19:14 ` Rafael J. Wysocki
  2010-07-03  0:03   ` Alan Stern
  2010-07-06 13:58   ` [PATCH ver. 2] " Alan Stern
  1 sibling, 2 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2010-07-02 19:14 UTC (permalink / raw)
  To: Alan Stern; +Cc: Linux-pm mailing list, Dominik Brodowski

On Friday, July 02, 2010, Alan Stern wrote:
> This patch (as1404) makes the runtime_status sysfs attribute available
> even in the absence of CONFIG_PM_ADVANCED_DEBUG, and it changes the
> routine to display "unknown" when runtime PM is disabled for a device.
> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> 
> ---
> 
> Maybe "unsupported" would be a little better than "unknown".  What do 
> you think?

I thought about that.  "Unsupported" seems to suggest that the device/driver
doesn't support runtime PM, whiile in fact it may be supported, although it's
not enabled at the moment.

Rafael


> Index: usb-2.6/drivers/base/power/sysfs.c
> ===================================================================
> --- usb-2.6.orig/drivers/base/power/sysfs.c
> +++ usb-2.6/drivers/base/power/sysfs.c
> @@ -108,6 +108,38 @@ static ssize_t control_store(struct devi
>  }
>  
>  static DEVICE_ATTR(control, 0644, control_show, control_store);
> +
> +static ssize_t rtpm_status_show(struct device *dev,
> +				struct device_attribute *attr, char *buf)
> +{
> +	const char *p;
> +
> +	if (dev->power.runtime_error) {
> +		p = "error\n";
> +	} else if (dev->power.disable_depth) {
> +		p = "unknown\n";
> +	} else {
> +		switch (dev->power.runtime_status) {
> +		case RPM_SUSPENDED:
> +			p = "suspended\n";
> +			break;
> +		case RPM_SUSPENDING:
> +			p = "suspending\n";
> +			break;
> +		case RPM_RESUMING:
> +			p = "resuming\n";
> +			break;
> +		case RPM_ACTIVE:
> +			p = "active\n";
> +			break;
> +		default:
> +			return -EIO;
> +		}
> +	}
> +	return sprintf(buf, p);
> +}
> +
> +static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
>  #endif
>  
>  static ssize_t
> @@ -172,27 +204,8 @@ static ssize_t rtpm_enabled_show(struct 
>  	return sprintf(buf, "enabled\n");
>  }
>  
> -static ssize_t rtpm_status_show(struct device *dev,
> -				struct device_attribute *attr, char *buf)
> -{
> -	if (dev->power.runtime_error)
> -		return sprintf(buf, "error\n");
> -	switch (dev->power.runtime_status) {
> -	case RPM_SUSPENDED:
> -		return sprintf(buf, "suspended\n");
> -	case RPM_SUSPENDING:
> -		return sprintf(buf, "suspending\n");
> -	case RPM_RESUMING:
> -		return sprintf(buf, "resuming\n");
> -	case RPM_ACTIVE:
> -		return sprintf(buf, "active\n");
> -	}
> -	return -EIO;
> -}
> -
>  static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
>  static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
> -static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
>  static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
>  
>  #endif
> @@ -228,6 +241,7 @@ static DEVICE_ATTR(async, 0644, async_sh
>  static struct attribute * power_attrs[] = {
>  #ifdef CONFIG_PM_RUNTIME
>  	&dev_attr_control.attr,
> +	&dev_attr_runtime_status.attr,
>  #endif
>  	&dev_attr_wakeup.attr,
>  #ifdef CONFIG_PM_ADVANCED_DEBUG
> @@ -235,7 +249,6 @@ static struct attribute * power_attrs[] 
>  #ifdef CONFIG_PM_RUNTIME
>  	&dev_attr_runtime_usage.attr,
>  	&dev_attr_runtime_active_kids.attr,
> -	&dev_attr_runtime_status.attr,
>  	&dev_attr_runtime_enabled.attr,
>  #endif
>  #endif
> 
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PM: make runtime_status attribute not debug-only
  2010-07-02 19:14 ` Rafael J. Wysocki
@ 2010-07-03  0:03   ` Alan Stern
  2010-07-03 19:29     ` Rafael J. Wysocki
  2010-07-06 13:58   ` [PATCH ver. 2] " Alan Stern
  1 sibling, 1 reply; 7+ messages in thread
From: Alan Stern @ 2010-07-03  0:03 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux-pm mailing list, Dominik Brodowski

On Fri, 2 Jul 2010, Rafael J. Wysocki wrote:

> On Friday, July 02, 2010, Alan Stern wrote:
> > This patch (as1404) makes the runtime_status sysfs attribute available
> > even in the absence of CONFIG_PM_ADVANCED_DEBUG, and it changes the
> > routine to display "unknown" when runtime PM is disabled for a device.
> > 
> > Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> > 
> > ---
> > 
> > Maybe "unsupported" would be a little better than "unknown".  What do 
> > you think?
> 
> I thought about that.  "Unsupported" seems to suggest that the device/driver
> doesn't support runtime PM, whiile in fact it may be supported, although it's
> not enabled at the moment.

Drivers that support runtime PM generally don't leave it disabled for 
very long.  IMO this wouldn't be terribly misleading.

You can change the patch, or if you prefer, I'll submit a revised 
version in a few days.

Alan Stern

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] PM: make runtime_status attribute not debug-only
  2010-07-03  0:03   ` Alan Stern
@ 2010-07-03 19:29     ` Rafael J. Wysocki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2010-07-03 19:29 UTC (permalink / raw)
  To: Alan Stern; +Cc: Linux-pm mailing list, Dominik Brodowski

On Saturday, July 03, 2010, Alan Stern wrote:
> On Fri, 2 Jul 2010, Rafael J. Wysocki wrote:
> 
> > On Friday, July 02, 2010, Alan Stern wrote:
> > > This patch (as1404) makes the runtime_status sysfs attribute available
> > > even in the absence of CONFIG_PM_ADVANCED_DEBUG, and it changes the
> > > routine to display "unknown" when runtime PM is disabled for a device.
> > > 
> > > Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> > > 
> > > ---
> > > 
> > > Maybe "unsupported" would be a little better than "unknown".  What do 
> > > you think?
> > 
> > I thought about that.  "Unsupported" seems to suggest that the device/driver
> > doesn't support runtime PM, whiile in fact it may be supported, although it's
> > not enabled at the moment.
> 
> Drivers that support runtime PM generally don't leave it disabled for 
> very long.  IMO this wouldn't be terribly misleading.

Well, whatever.  I'm fine with that either way.

Rafael

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH ver. 2] PM: make runtime_status attribute not debug-only
  2010-07-02 19:14 ` Rafael J. Wysocki
  2010-07-03  0:03   ` Alan Stern
@ 2010-07-06 13:58   ` Alan Stern
  2010-07-07 22:54     ` Rafael J. Wysocki
  1 sibling, 1 reply; 7+ messages in thread
From: Alan Stern @ 2010-07-06 13:58 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux-pm mailing list, Dominik Brodowski

This patch (as1404b) makes the runtime_status sysfs attribute available
even in the absence of CONFIG_PM_ADVANCED_DEBUG, and it changes the
routine to display "unsupported" when runtime PM is disabled for a
device.  Although not strictly 100% accurate, this will almost always
be correct.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Dominik Brodowski <linux@dominikbrodowski.net>

---

Index: usb-2.6/drivers/base/power/sysfs.c
===================================================================
--- usb-2.6.orig/drivers/base/power/sysfs.c
+++ usb-2.6/drivers/base/power/sysfs.c
@@ -108,6 +108,38 @@ static ssize_t control_store(struct devi
 }
 
 static DEVICE_ATTR(control, 0644, control_show, control_store);
+
+static ssize_t rtpm_status_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	const char *p;
+
+	if (dev->power.runtime_error) {
+		p = "error\n";
+	} else if (dev->power.disable_depth) {
+		p = "unsupported\n";
+	} else {
+		switch (dev->power.runtime_status) {
+		case RPM_SUSPENDED:
+			p = "suspended\n";
+			break;
+		case RPM_SUSPENDING:
+			p = "suspending\n";
+			break;
+		case RPM_RESUMING:
+			p = "resuming\n";
+			break;
+		case RPM_ACTIVE:
+			p = "active\n";
+			break;
+		default:
+			return -EIO;
+		}
+	}
+	return sprintf(buf, p);
+}
+
+static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
 #endif
 
 static ssize_t
@@ -172,27 +204,8 @@ static ssize_t rtpm_enabled_show(struct 
 	return sprintf(buf, "enabled\n");
 }
 
-static ssize_t rtpm_status_show(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	if (dev->power.runtime_error)
-		return sprintf(buf, "error\n");
-	switch (dev->power.runtime_status) {
-	case RPM_SUSPENDED:
-		return sprintf(buf, "suspended\n");
-	case RPM_SUSPENDING:
-		return sprintf(buf, "suspending\n");
-	case RPM_RESUMING:
-		return sprintf(buf, "resuming\n");
-	case RPM_ACTIVE:
-		return sprintf(buf, "active\n");
-	}
-	return -EIO;
-}
-
 static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
 static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
-static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
 static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
 
 #endif
@@ -228,6 +241,7 @@ static DEVICE_ATTR(async, 0644, async_sh
 static struct attribute * power_attrs[] = {
 #ifdef CONFIG_PM_RUNTIME
 	&dev_attr_control.attr,
+	&dev_attr_runtime_status.attr,
 #endif
 	&dev_attr_wakeup.attr,
 #ifdef CONFIG_PM_ADVANCED_DEBUG
@@ -235,7 +249,6 @@ static struct attribute * power_attrs[] 
 #ifdef CONFIG_PM_RUNTIME
 	&dev_attr_runtime_usage.attr,
 	&dev_attr_runtime_active_kids.attr,
-	&dev_attr_runtime_status.attr,
 	&dev_attr_runtime_enabled.attr,
 #endif
 #endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH ver. 2] PM: make runtime_status attribute not debug-only
  2010-07-06 13:58   ` [PATCH ver. 2] " Alan Stern
@ 2010-07-07 22:54     ` Rafael J. Wysocki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2010-07-07 22:54 UTC (permalink / raw)
  To: Alan Stern; +Cc: Linux-pm mailing list, Dominik Brodowski

On Tuesday, July 06, 2010, Alan Stern wrote:
> This patch (as1404b) makes the runtime_status sysfs attribute available
> even in the absence of CONFIG_PM_ADVANCED_DEBUG, and it changes the
> routine to display "unsupported" when runtime PM is disabled for a
> device.  Although not strictly 100% accurate, this will almost always
> be correct.
> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> Acked-by: Dominik Brodowski <linux@dominikbrodowski.net>

Applied to suspend-2.6/linux-next.

Thanks,
Rafael


> ---
> 
> Index: usb-2.6/drivers/base/power/sysfs.c
> ===================================================================
> --- usb-2.6.orig/drivers/base/power/sysfs.c
> +++ usb-2.6/drivers/base/power/sysfs.c
> @@ -108,6 +108,38 @@ static ssize_t control_store(struct devi
>  }
>  
>  static DEVICE_ATTR(control, 0644, control_show, control_store);
> +
> +static ssize_t rtpm_status_show(struct device *dev,
> +				struct device_attribute *attr, char *buf)
> +{
> +	const char *p;
> +
> +	if (dev->power.runtime_error) {
> +		p = "error\n";
> +	} else if (dev->power.disable_depth) {
> +		p = "unsupported\n";
> +	} else {
> +		switch (dev->power.runtime_status) {
> +		case RPM_SUSPENDED:
> +			p = "suspended\n";
> +			break;
> +		case RPM_SUSPENDING:
> +			p = "suspending\n";
> +			break;
> +		case RPM_RESUMING:
> +			p = "resuming\n";
> +			break;
> +		case RPM_ACTIVE:
> +			p = "active\n";
> +			break;
> +		default:
> +			return -EIO;
> +		}
> +	}
> +	return sprintf(buf, p);
> +}
> +
> +static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
>  #endif
>  
>  static ssize_t
> @@ -172,27 +204,8 @@ static ssize_t rtpm_enabled_show(struct 
>  	return sprintf(buf, "enabled\n");
>  }
>  
> -static ssize_t rtpm_status_show(struct device *dev,
> -				struct device_attribute *attr, char *buf)
> -{
> -	if (dev->power.runtime_error)
> -		return sprintf(buf, "error\n");
> -	switch (dev->power.runtime_status) {
> -	case RPM_SUSPENDED:
> -		return sprintf(buf, "suspended\n");
> -	case RPM_SUSPENDING:
> -		return sprintf(buf, "suspending\n");
> -	case RPM_RESUMING:
> -		return sprintf(buf, "resuming\n");
> -	case RPM_ACTIVE:
> -		return sprintf(buf, "active\n");
> -	}
> -	return -EIO;
> -}
> -
>  static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
>  static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
> -static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
>  static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
>  
>  #endif
> @@ -228,6 +241,7 @@ static DEVICE_ATTR(async, 0644, async_sh
>  static struct attribute * power_attrs[] = {
>  #ifdef CONFIG_PM_RUNTIME
>  	&dev_attr_control.attr,
> +	&dev_attr_runtime_status.attr,
>  #endif
>  	&dev_attr_wakeup.attr,
>  #ifdef CONFIG_PM_ADVANCED_DEBUG
> @@ -235,7 +249,6 @@ static struct attribute * power_attrs[] 
>  #ifdef CONFIG_PM_RUNTIME
>  	&dev_attr_runtime_usage.attr,
>  	&dev_attr_runtime_active_kids.attr,
> -	&dev_attr_runtime_status.attr,
>  	&dev_attr_runtime_enabled.attr,
>  #endif
>  #endif
> 
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-07 22:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-02 16:51 [PATCH] PM: make runtime_status attribute not debug-only Alan Stern
2010-07-02 18:29 ` Dominik Brodowski
2010-07-02 19:14 ` Rafael J. Wysocki
2010-07-03  0:03   ` Alan Stern
2010-07-03 19:29     ` Rafael J. Wysocki
2010-07-06 13:58   ` [PATCH ver. 2] " Alan Stern
2010-07-07 22:54     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox