aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/main.c
diff options
context:
space:
mode:
authorSameer Nanda <snanda@chromium.org>2012-06-19 22:23:33 +0200
committerRafael J. Wysocki <rjw@sisk.pl>2012-07-01 13:31:22 +0200
commit4b7760ba0dd3319f66886ab2335a0fbecdbc808a (patch)
treef619ead7186c286a5f8c786091af8c46de0decf3 /kernel/power/main.c
parentftrace: Disable function tracing during suspend/resume and hibernation, again (diff)
downloadlinux-dev-4b7760ba0dd3319f66886ab2335a0fbecdbc808a.tar.xz
linux-dev-4b7760ba0dd3319f66886ab2335a0fbecdbc808a.zip
PM / Sleep: add knob for printing device resume times
Added a new knob called /sys/power/pm_print_times. Setting it to 1 enables printing of time taken by devices to suspend and resume. Setting it to 0 disables this printing (unless overridden by initcall_debug kernel command line option). Signed-off-by: Sameer Nanda <snanda@chromium.org> Acked-by: Greg KH <gregkh@linuxfoundation.org> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to '')
-rw-r--r--kernel/power/main.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 428f8a034e96..7beb3fb3670b 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -132,6 +132,38 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
}
power_attr(pm_test);
+
+/*
+ * pm_print_times: print time taken by devices to suspend and resume.
+ *
+ * show() returns whether printing of suspend and resume times is enabled.
+ * store() accepts 0 or 1. 0 disables printing and 1 enables it.
+ */
+int pm_print_times_enabled;
+
+static ssize_t pm_print_times_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", pm_print_times_enabled);
+}
+
+static ssize_t pm_print_times_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t n)
+{
+ unsigned long val;
+
+ if (kstrtoul(buf, 10, &val))
+ return -EINVAL;
+
+ if (val > 1)
+ return -EINVAL;
+
+ pm_print_times_enabled = val;
+ return n;
+}
+
+power_attr(pm_print_times);
#endif /* CONFIG_PM_DEBUG */
#ifdef CONFIG_DEBUG_FS
@@ -530,6 +562,7 @@ static struct attribute * g[] = {
#endif
#ifdef CONFIG_PM_DEBUG
&pm_test_attr.attr,
+ &pm_print_times_attr.attr,
#endif
#endif
NULL,