diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-07-07 18:05:37 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2010-07-18 20:00:36 -0400 |
commit | 0fcb4eef8294492c8f1de8236b1ed81f09e42922 (patch) | |
tree | 23c96ecfc5a85c1870d85c5db9421b6c09763fa8 /drivers/base/power | |
parent | 4eb241e5691363c391aac8a5051d0d013188ec84 (diff) |
PM / Runtime: Make runtime_status attribute not debug-only (v. 2)
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>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base/power')
-rw-r--r-- | drivers/base/power/sysfs.c | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 81d344e0e95d..1eca50c8e7ca 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c | |||
@@ -110,6 +110,38 @@ static ssize_t control_store(struct device * dev, struct device_attribute *attr, | |||
110 | } | 110 | } |
111 | 111 | ||
112 | static DEVICE_ATTR(control, 0644, control_show, control_store); | 112 | static DEVICE_ATTR(control, 0644, control_show, control_store); |
113 | |||
114 | static ssize_t rtpm_status_show(struct device *dev, | ||
115 | struct device_attribute *attr, char *buf) | ||
116 | { | ||
117 | const char *p; | ||
118 | |||
119 | if (dev->power.runtime_error) { | ||
120 | p = "error\n"; | ||
121 | } else if (dev->power.disable_depth) { | ||
122 | p = "unsupported\n"; | ||
123 | } else { | ||
124 | switch (dev->power.runtime_status) { | ||
125 | case RPM_SUSPENDED: | ||
126 | p = "suspended\n"; | ||
127 | break; | ||
128 | case RPM_SUSPENDING: | ||
129 | p = "suspending\n"; | ||
130 | break; | ||
131 | case RPM_RESUMING: | ||
132 | p = "resuming\n"; | ||
133 | break; | ||
134 | case RPM_ACTIVE: | ||
135 | p = "active\n"; | ||
136 | break; | ||
137 | default: | ||
138 | return -EIO; | ||
139 | } | ||
140 | } | ||
141 | return sprintf(buf, p); | ||
142 | } | ||
143 | |||
144 | static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL); | ||
113 | #endif | 145 | #endif |
114 | 146 | ||
115 | static ssize_t | 147 | static ssize_t |
@@ -184,27 +216,8 @@ static ssize_t rtpm_enabled_show(struct device *dev, | |||
184 | return sprintf(buf, "enabled\n"); | 216 | return sprintf(buf, "enabled\n"); |
185 | } | 217 | } |
186 | 218 | ||
187 | static ssize_t rtpm_status_show(struct device *dev, | ||
188 | struct device_attribute *attr, char *buf) | ||
189 | { | ||
190 | if (dev->power.runtime_error) | ||
191 | return sprintf(buf, "error\n"); | ||
192 | switch (dev->power.runtime_status) { | ||
193 | case RPM_SUSPENDED: | ||
194 | return sprintf(buf, "suspended\n"); | ||
195 | case RPM_SUSPENDING: | ||
196 | return sprintf(buf, "suspending\n"); | ||
197 | case RPM_RESUMING: | ||
198 | return sprintf(buf, "resuming\n"); | ||
199 | case RPM_ACTIVE: | ||
200 | return sprintf(buf, "active\n"); | ||
201 | } | ||
202 | return -EIO; | ||
203 | } | ||
204 | |||
205 | static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL); | 219 | static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL); |
206 | static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL); | 220 | static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL); |
207 | static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL); | ||
208 | static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL); | 221 | static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL); |
209 | 222 | ||
210 | #endif | 223 | #endif |
@@ -240,6 +253,7 @@ static DEVICE_ATTR(async, 0644, async_show, async_store); | |||
240 | static struct attribute * power_attrs[] = { | 253 | static struct attribute * power_attrs[] = { |
241 | #ifdef CONFIG_PM_RUNTIME | 254 | #ifdef CONFIG_PM_RUNTIME |
242 | &dev_attr_control.attr, | 255 | &dev_attr_control.attr, |
256 | &dev_attr_runtime_status.attr, | ||
243 | #endif | 257 | #endif |
244 | &dev_attr_wakeup.attr, | 258 | &dev_attr_wakeup.attr, |
245 | #ifdef CONFIG_PM_SLEEP | 259 | #ifdef CONFIG_PM_SLEEP |
@@ -250,7 +264,6 @@ static struct attribute * power_attrs[] = { | |||
250 | #ifdef CONFIG_PM_RUNTIME | 264 | #ifdef CONFIG_PM_RUNTIME |
251 | &dev_attr_runtime_usage.attr, | 265 | &dev_attr_runtime_usage.attr, |
252 | &dev_attr_runtime_active_kids.attr, | 266 | &dev_attr_runtime_active_kids.attr, |
253 | &dev_attr_runtime_status.attr, | ||
254 | &dev_attr_runtime_enabled.attr, | 267 | &dev_attr_runtime_enabled.attr, |
255 | #endif | 268 | #endif |
256 | #endif | 269 | #endif |