diff options
-rw-r--r-- | drivers/base/power/sysfs.c | 65 |
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 | ||
144 | static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); | 145 | static 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 | |||
150 | static 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 | |||
156 | static 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 | |||
163 | static 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 | |||
175 | static 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 | |||
193 | static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL); | ||
194 | static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL); | ||
195 | static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL); | ||
196 | static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL); | ||
197 | |||
198 | #endif | ||
199 | |||
147 | static ssize_t async_show(struct device *dev, struct device_attribute *attr, | 200 | static 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 | ||
172 | static DEVICE_ATTR(async, 0644, async_show, async_store); | 225 | static DEVICE_ATTR(async, 0644, async_show, async_store); |
173 | #endif /* CONFIG_PM_SLEEP_ADVANCED_DEBUG */ | 226 | #endif /* CONFIG_PM_ADVANCED_DEBUG */ |
174 | 227 | ||
175 | static struct attribute * power_attrs[] = { | 228 | static 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 | }; |