aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/power/main.c')
-rw-r--r--kernel/power/main.c64
1 files changed, 59 insertions, 5 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 42bd800a6755..3a2ca9066583 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -150,7 +150,7 @@ static ssize_t mem_sleep_store(struct kobject *kobj, struct kobj_attribute *attr
150power_attr(mem_sleep); 150power_attr(mem_sleep);
151#endif /* CONFIG_SUSPEND */ 151#endif /* CONFIG_SUSPEND */
152 152
153#ifdef CONFIG_PM_DEBUG 153#ifdef CONFIG_PM_SLEEP_DEBUG
154int pm_test_level = TEST_NONE; 154int pm_test_level = TEST_NONE;
155 155
156static const char * const pm_tests[__TEST_AFTER_LAST] = { 156static const char * const pm_tests[__TEST_AFTER_LAST] = {
@@ -211,7 +211,7 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
211} 211}
212 212
213power_attr(pm_test); 213power_attr(pm_test);
214#endif /* CONFIG_PM_DEBUG */ 214#endif /* CONFIG_PM_SLEEP_DEBUG */
215 215
216#ifdef CONFIG_DEBUG_FS 216#ifdef CONFIG_DEBUG_FS
217static char *suspend_step_name(enum suspend_stat_step step) 217static char *suspend_step_name(enum suspend_stat_step step)
@@ -361,6 +361,61 @@ static ssize_t pm_wakeup_irq_show(struct kobject *kobj,
361 361
362power_attr_ro(pm_wakeup_irq); 362power_attr_ro(pm_wakeup_irq);
363 363
364bool pm_debug_messages_on __read_mostly;
365
366static ssize_t pm_debug_messages_show(struct kobject *kobj,
367 struct kobj_attribute *attr, char *buf)
368{
369 return sprintf(buf, "%d\n", pm_debug_messages_on);
370}
371
372static ssize_t pm_debug_messages_store(struct kobject *kobj,
373 struct kobj_attribute *attr,
374 const char *buf, size_t n)
375{
376 unsigned long val;
377
378 if (kstrtoul(buf, 10, &val))
379 return -EINVAL;
380
381 if (val > 1)
382 return -EINVAL;
383
384 pm_debug_messages_on = !!val;
385 return n;
386}
387
388power_attr(pm_debug_messages);
389
390/**
391 * __pm_pr_dbg - Print a suspend debug message to the kernel log.
392 * @defer: Whether or not to use printk_deferred() to print the message.
393 * @fmt: Message format.
394 *
395 * The message will be emitted if enabled through the pm_debug_messages
396 * sysfs attribute.
397 */
398void __pm_pr_dbg(bool defer, const char *fmt, ...)
399{
400 struct va_format vaf;
401 va_list args;
402
403 if (!pm_debug_messages_on)
404 return;
405
406 va_start(args, fmt);
407
408 vaf.fmt = fmt;
409 vaf.va = &args;
410
411 if (defer)
412 printk_deferred(KERN_DEBUG "PM: %pV", &vaf);
413 else
414 printk(KERN_DEBUG "PM: %pV", &vaf);
415
416 va_end(args);
417}
418
364#else /* !CONFIG_PM_SLEEP_DEBUG */ 419#else /* !CONFIG_PM_SLEEP_DEBUG */
365static inline void pm_print_times_init(void) {} 420static inline void pm_print_times_init(void) {}
366#endif /* CONFIG_PM_SLEEP_DEBUG */ 421#endif /* CONFIG_PM_SLEEP_DEBUG */
@@ -691,12 +746,11 @@ static struct attribute * g[] = {
691 &wake_lock_attr.attr, 746 &wake_lock_attr.attr,
692 &wake_unlock_attr.attr, 747 &wake_unlock_attr.attr,
693#endif 748#endif
694#ifdef CONFIG_PM_DEBUG
695 &pm_test_attr.attr,
696#endif
697#ifdef CONFIG_PM_SLEEP_DEBUG 749#ifdef CONFIG_PM_SLEEP_DEBUG
750 &pm_test_attr.attr,
698 &pm_print_times_attr.attr, 751 &pm_print_times_attr.attr,
699 &pm_wakeup_irq_attr.attr, 752 &pm_wakeup_irq_attr.attr,
753 &pm_debug_messages_attr.attr,
700#endif 754#endif
701#endif 755#endif
702#ifdef CONFIG_FREEZER 756#ifdef CONFIG_FREEZER