aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/main.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-06-20 18:19:33 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-07-01 07:31:23 -0400
commitb2df1d4f8b95d9d1e3f064cef02fc5c5116b05cf (patch)
tree6e891ad6ad748ea737ab5774983f90d9be720446 /kernel/power/main.c
parent4b7760ba0dd3319f66886ab2335a0fbecdbc808a (diff)
PM / Sleep: Separate printing suspend times from initcall_debug
Change the behavior of the newly introduced /sys/power/pm_print_times attribute so that its initial value depends on initcall_debug, but setting it to 0 will cause device suspend/resume times not to be printed, even if initcall_debug has been set. This way, the people who use initcall_debug for reasons other than PM debugging will be able to switch the suspend/resume times printing off, if need be. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/power/main.c')
-rw-r--r--kernel/power/main.c76
1 files changed, 44 insertions, 32 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 7beb3fb3670b..f458238109cc 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -132,38 +132,6 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
132} 132}
133 133
134power_attr(pm_test); 134power_attr(pm_test);
135
136/*
137 * pm_print_times: print time taken by devices to suspend and resume.
138 *
139 * show() returns whether printing of suspend and resume times is enabled.
140 * store() accepts 0 or 1. 0 disables printing and 1 enables it.
141 */
142int pm_print_times_enabled;
143
144static ssize_t pm_print_times_show(struct kobject *kobj,
145 struct kobj_attribute *attr, char *buf)
146{
147 return sprintf(buf, "%d\n", pm_print_times_enabled);
148}
149
150static ssize_t pm_print_times_store(struct kobject *kobj,
151 struct kobj_attribute *attr,
152 const char *buf, size_t n)
153{
154 unsigned long val;
155
156 if (kstrtoul(buf, 10, &val))
157 return -EINVAL;
158
159 if (val > 1)
160 return -EINVAL;
161
162 pm_print_times_enabled = val;
163 return n;
164}
165
166power_attr(pm_print_times);
167#endif /* CONFIG_PM_DEBUG */ 135#endif /* CONFIG_PM_DEBUG */
168 136
169#ifdef CONFIG_DEBUG_FS 137#ifdef CONFIG_DEBUG_FS
@@ -267,6 +235,47 @@ late_initcall(pm_debugfs_init);
267 235
268#endif /* CONFIG_PM_SLEEP */ 236#endif /* CONFIG_PM_SLEEP */
269 237
238#ifdef CONFIG_PM_SLEEP_DEBUG
239/*
240 * pm_print_times: print time taken by devices to suspend and resume.
241 *
242 * show() returns whether printing of suspend and resume times is enabled.
243 * store() accepts 0 or 1. 0 disables printing and 1 enables it.
244 */
245bool pm_print_times_enabled;
246
247static ssize_t pm_print_times_show(struct kobject *kobj,
248 struct kobj_attribute *attr, char *buf)
249{
250 return sprintf(buf, "%d\n", pm_print_times_enabled);
251}
252
253static ssize_t pm_print_times_store(struct kobject *kobj,
254 struct kobj_attribute *attr,
255 const char *buf, size_t n)
256{
257 unsigned long val;
258
259 if (kstrtoul(buf, 10, &val))
260 return -EINVAL;
261
262 if (val > 1)
263 return -EINVAL;
264
265 pm_print_times_enabled = !!val;
266 return n;
267}
268
269power_attr(pm_print_times);
270
271static inline void pm_print_times_init(void)
272{
273 pm_print_times_enabled = !!initcall_debug;
274}
275#else /* !CONFIG_PP_SLEEP_DEBUG */
276static inline void pm_print_times_init(void) {}
277#endif /* CONFIG_PM_SLEEP_DEBUG */
278
270struct kobject *power_kobj; 279struct kobject *power_kobj;
271 280
272/** 281/**
@@ -562,6 +571,8 @@ static struct attribute * g[] = {
562#endif 571#endif
563#ifdef CONFIG_PM_DEBUG 572#ifdef CONFIG_PM_DEBUG
564 &pm_test_attr.attr, 573 &pm_test_attr.attr,
574#endif
575#ifdef CONFIG_PM_SLEEP_DEBUG
565 &pm_print_times_attr.attr, 576 &pm_print_times_attr.attr,
566#endif 577#endif
567#endif 578#endif
@@ -599,6 +610,7 @@ static int __init pm_init(void)
599 error = sysfs_create_group(power_kobj, &attr_group); 610 error = sysfs_create_group(power_kobj, &attr_group);
600 if (error) 611 if (error)
601 return error; 612 return error;
613 pm_print_times_init();
602 return pm_autosleep_init(); 614 return pm_autosleep_init();
603} 615}
604 616