diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2010-01-23 16:25:23 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2010-02-26 14:39:10 -0500 |
commit | 5a2eb8585f3b38e01e30aacaa8b985a1520a993d (patch) | |
tree | 471b33cc48cf48ed491e8b3f2934bfb3fa9e81e1 /drivers/base | |
parent | 0e06b4a891c6a108412fe24b4500f499da2cf8a1 (diff) |
PM: Add facility for advanced testing of async suspend/resume
Add configuration switch CONFIG_PM_ADVANCED_DEBUG for compiling in
extra PM debugging/testing code allowing one to access some
PM-related attributes of devices from the user space via sysfs.
If CONFIG_PM_ADVANCED_DEBUG is set, add sysfs attribute power/async
for every device allowing the user space to access the device's
power.async_suspend flag and modify it, if desired.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/power/sysfs.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index c011ff15632c..86fd9373447e 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c | |||
@@ -54,6 +54,24 @@ | |||
54 | * wakeup events internally (unless they are disabled), keeping | 54 | * wakeup events internally (unless they are disabled), keeping |
55 | * their hardware in low power modes whenever they're unused. This | 55 | * their hardware in low power modes whenever they're unused. This |
56 | * saves runtime power, without requiring system-wide sleep states. | 56 | * saves runtime power, without requiring system-wide sleep states. |
57 | * | ||
58 | * async - Report/change current async suspend setting for the device | ||
59 | * | ||
60 | * Asynchronous suspend and resume of the device during system-wide power | ||
61 | * state transitions can be enabled by writing "enabled" to this file. | ||
62 | * Analogously, if "disabled" is written to this file, the device will be | ||
63 | * suspended and resumed synchronously. | ||
64 | * | ||
65 | * All devices have one of the following two values for power/async: | ||
66 | * | ||
67 | * + "enabled\n" to permit the asynchronous suspend/resume of the device; | ||
68 | * + "disabled\n" to forbid it; | ||
69 | * | ||
70 | * NOTE: It generally is unsafe to permit the asynchronous suspend/resume | ||
71 | * of a device unless it is certain that all of the PM dependencies of the | ||
72 | * device are known to the PM core. However, for some devices this | ||
73 | * attribute is set to "enabled" by bus type code or device drivers and in | ||
74 | * that cases it should be safe to leave the default value. | ||
57 | */ | 75 | */ |
58 | 76 | ||
59 | static const char enabled[] = "enabled"; | 77 | static const char enabled[] = "enabled"; |
@@ -125,12 +143,43 @@ wake_store(struct device * dev, struct device_attribute *attr, | |||
125 | 143 | ||
126 | static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); | 144 | static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); |
127 | 145 | ||
146 | #ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG | ||
147 | static ssize_t async_show(struct device *dev, struct device_attribute *attr, | ||
148 | char *buf) | ||
149 | { | ||
150 | return sprintf(buf, "%s\n", | ||
151 | device_async_suspend_enabled(dev) ? enabled : disabled); | ||
152 | } | ||
153 | |||
154 | static ssize_t async_store(struct device *dev, struct device_attribute *attr, | ||
155 | const char *buf, size_t n) | ||
156 | { | ||
157 | char *cp; | ||
158 | int len = n; | ||
159 | |||
160 | cp = memchr(buf, '\n', n); | ||
161 | if (cp) | ||
162 | len = cp - buf; | ||
163 | if (len == sizeof enabled - 1 && strncmp(buf, enabled, len) == 0) | ||
164 | device_enable_async_suspend(dev); | ||
165 | else if (len == sizeof disabled - 1 && strncmp(buf, disabled, len) == 0) | ||
166 | device_disable_async_suspend(dev); | ||
167 | else | ||
168 | return -EINVAL; | ||
169 | return n; | ||
170 | } | ||
171 | |||
172 | static DEVICE_ATTR(async, 0644, async_show, async_store); | ||
173 | #endif /* CONFIG_PM_SLEEP_ADVANCED_DEBUG */ | ||
128 | 174 | ||
129 | static struct attribute * power_attrs[] = { | 175 | static struct attribute * power_attrs[] = { |
130 | #ifdef CONFIG_PM_RUNTIME | 176 | #ifdef CONFIG_PM_RUNTIME |
131 | &dev_attr_control.attr, | 177 | &dev_attr_control.attr, |
132 | #endif | 178 | #endif |
133 | &dev_attr_wakeup.attr, | 179 | &dev_attr_wakeup.attr, |
180 | #ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG | ||
181 | &dev_attr_async.attr, | ||
182 | #endif | ||
134 | NULL, | 183 | NULL, |
135 | }; | 184 | }; |
136 | static struct attribute_group pm_attr_group = { | 185 | static struct attribute_group pm_attr_group = { |