aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-04-23 14:32:23 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2010-05-10 17:08:17 -0400
commitc92445fadb9179d811b5cb044947ad4712403541 (patch)
tree7e314fd096afdd220169068a281a1e8e0a8b1e7d
parentd6f9cda1fd241bc7a1d896da94950fd972eca9b7 (diff)
PM / Runtime: Add sysfs debug files
Add a few sysfs files relating to runtime power management for advanced debug purposes: runtime_enabled: is runtime PM enabled for this device? States are "enabled", "disabled", "forbidden" or a combination of the latter two. runtime_status: what state is the device in currently? E.g., it reports "suspended" for runtime-suspended devices, and "active" for active devices. NOTE: if runtime_enabled returns "disabled", the value of this file may not reflect its physical state. runtime_usage: the runtime PM usage count of a device runtime_active_kids: the runtime PM children usage count of a device, or 0 if the ignore_children flag is set. Also, CONFIG_PM_SLEEP_ADVANCED_DEBUG is not defined in any Kconfig file, so replace it with CONFIG_PM_ADVANCED_DEBUG. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
-rw-r--r--drivers/base/power/sysfs.c65
1 files changed, 62 insertions, 3 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 86fd9373447e..a4c33bc51257 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -5,6 +5,7 @@
5#include <linux/device.h> 5#include <linux/device.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/pm_runtime.h> 7#include <linux/pm_runtime.h>
8#include <asm/atomic.h>
8#include "power.h" 9#include "power.h"
9 10
10/* 11/*
@@ -143,7 +144,59 @@ wake_store(struct device * dev, struct device_attribute *attr,
143 144
144static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); 145static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
145 146
146#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG 147#ifdef CONFIG_PM_ADVANCED_DEBUG
148#ifdef CONFIG_PM_RUNTIME
149
150static ssize_t rtpm_usagecount_show(struct device *dev,
151 struct device_attribute *attr, char *buf)
152{
153 return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count));
154}
155
156static ssize_t rtpm_children_show(struct device *dev,
157 struct device_attribute *attr, char *buf)
158{
159 return sprintf(buf, "%d\n", dev->power.ignore_children ?
160 0 : atomic_read(&dev->power.child_count));
161}
162
163static ssize_t rtpm_enabled_show(struct device *dev,
164 struct device_attribute *attr, char *buf)
165{
166 if ((dev->power.disable_depth) && (dev->power.runtime_auto == false))
167 return sprintf(buf, "disabled & forbidden\n");
168 else if (dev->power.disable_depth)
169 return sprintf(buf, "disabled\n");
170 else if (dev->power.runtime_auto == false)
171 return sprintf(buf, "forbidden\n");
172 return sprintf(buf, "enabled\n");
173}
174
175static ssize_t rtpm_status_show(struct device *dev,
176 struct device_attribute *attr, char *buf)
177{
178 if (dev->power.runtime_error)
179 return sprintf(buf, "error\n");
180 switch (dev->power.runtime_status) {
181 case RPM_SUSPENDED:
182 return sprintf(buf, "suspended\n");
183 case RPM_SUSPENDING:
184 return sprintf(buf, "suspending\n");
185 case RPM_RESUMING:
186 return sprintf(buf, "resuming\n");
187 case RPM_ACTIVE:
188 return sprintf(buf, "active\n");
189 }
190 return -EIO;
191}
192
193static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
194static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
195static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
196static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
197
198#endif
199
147static ssize_t async_show(struct device *dev, struct device_attribute *attr, 200static ssize_t async_show(struct device *dev, struct device_attribute *attr,
148 char *buf) 201 char *buf)
149{ 202{
@@ -170,15 +223,21 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
170} 223}
171 224
172static DEVICE_ATTR(async, 0644, async_show, async_store); 225static DEVICE_ATTR(async, 0644, async_show, async_store);
173#endif /* CONFIG_PM_SLEEP_ADVANCED_DEBUG */ 226#endif /* CONFIG_PM_ADVANCED_DEBUG */
174 227
175static struct attribute * power_attrs[] = { 228static struct attribute * power_attrs[] = {
176#ifdef CONFIG_PM_RUNTIME 229#ifdef CONFIG_PM_RUNTIME
177 &dev_attr_control.attr, 230 &dev_attr_control.attr,
178#endif 231#endif
179 &dev_attr_wakeup.attr, 232 &dev_attr_wakeup.attr,
180#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG 233#ifdef CONFIG_PM_ADVANCED_DEBUG
181 &dev_attr_async.attr, 234 &dev_attr_async.attr,
235#ifdef CONFIG_PM_RUNTIME
236 &dev_attr_runtime_usage.attr,
237 &dev_attr_runtime_active_kids.attr,
238 &dev_attr_runtime_status.attr,
239 &dev_attr_runtime_enabled.attr,
240#endif
182#endif 241#endif
183 NULL, 242 NULL,
184}; 243};