PM / Sleep: Add user space interface for manipulating wakeup sources, v3
[linux-2.6.git] / kernel / power / main.c
index ba6a564..54ec071 100644 (file)
@@ -431,6 +431,43 @@ static ssize_t autosleep_store(struct kobject *kobj,
 
 power_attr(autosleep);
 #endif /* CONFIG_PM_AUTOSLEEP */
+
+#ifdef CONFIG_PM_WAKELOCKS
+static ssize_t wake_lock_show(struct kobject *kobj,
+                             struct kobj_attribute *attr,
+                             char *buf)
+{
+       return pm_show_wakelocks(buf, true);
+}
+
+static ssize_t wake_lock_store(struct kobject *kobj,
+                              struct kobj_attribute *attr,
+                              const char *buf, size_t n)
+{
+       int error = pm_wake_lock(buf);
+       return error ? error : n;
+}
+
+power_attr(wake_lock);
+
+static ssize_t wake_unlock_show(struct kobject *kobj,
+                               struct kobj_attribute *attr,
+                               char *buf)
+{
+       return pm_show_wakelocks(buf, false);
+}
+
+static ssize_t wake_unlock_store(struct kobject *kobj,
+                                struct kobj_attribute *attr,
+                                const char *buf, size_t n)
+{
+       int error = pm_wake_unlock(buf);
+       return error ? error : n;
+}
+
+power_attr(wake_unlock);
+
+#endif /* CONFIG_PM_WAKELOCKS */
 #endif /* CONFIG_PM_SLEEP */
 
 #ifdef CONFIG_PM_TRACE
@@ -487,6 +524,10 @@ static struct attribute * g[] = {
 #ifdef CONFIG_PM_AUTOSLEEP
        &autosleep_attr.attr,
 #endif
+#ifdef CONFIG_PM_WAKELOCKS
+       &wake_lock_attr.attr,
+       &wake_unlock_attr.attr,
+#endif
 #ifdef CONFIG_PM_DEBUG
        &pm_test_attr.attr,
 #endif