aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/power/sysfs.c')
-rw-r--r--drivers/base/power/sysfs.c49
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
59static const char enabled[] = "enabled"; 77static const char enabled[] = "enabled";
@@ -125,12 +143,43 @@ wake_store(struct device * dev, struct device_attribute *attr,
125 143
126static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); 144static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
127 145
146#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG
147static 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
154static 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
172static DEVICE_ATTR(async, 0644, async_show, async_store);
173#endif /* CONFIG_PM_SLEEP_ADVANCED_DEBUG */
128 174
129static struct attribute * power_attrs[] = { 175static 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};
136static struct attribute_group pm_attr_group = { 185static struct attribute_group pm_attr_group = {