11 #include <linux/export.h>
13 #include <linux/string.h>
23 #ifdef CONFIG_PM_SLEEP
41 int pm_notifier_call_chain(
unsigned long val)
45 return notifier_to_errno(ret);
49 int pm_async_enabled = 1;
54 return sprintf(buf,
"%d\n", pm_async_enabled);
58 const char *
buf,
size_t n)
68 pm_async_enabled =
val;
74 #ifdef CONFIG_PM_DEBUG
93 if (pm_tests[level]) {
94 if (level == pm_test_level)
95 s +=
sprintf(s,
"[%s] ", pm_tests[level]);
97 s +=
sprintf(s,
"%s ", pm_tests[level]);
108 const char *buf,
size_t n)
110 const char *
const *
s;
117 len = p ? p - buf :
n;
122 for (s = &pm_tests[level]; level <=
TEST_MAX; s++, level++)
124 pm_test_level =
level;
129 unlock_system_sleep();
131 return error ? error :
n;
137 #ifdef CONFIG_DEBUG_FS
148 return "suspend_noirq";
150 return "resume_noirq";
160 int i,
index, last_dev, last_errno, last_step;
168 seq_printf(s,
"%s: %d\n%s: %d\n%s: %d\n%s: %d\n%s: %d\n"
169 "%s: %d\n%s: %d\n%s: %d\n%s: %d\n%s: %d\n",
175 "failed_suspend_late",
177 "failed_suspend_noirq",
180 "failed_resume_early",
182 "failed_resume_noirq",
184 seq_printf(s,
"failures:\n last_failed_dev:\t%-s\n",
187 index = last_dev + REC_FAILED_NUM -
i;
195 index = last_errno + REC_FAILED_NUM -
i;
204 index = last_step + REC_FAILED_NUM -
i;
220 .
open = suspend_stats_open,
226 static int __init pm_debugfs_init(
void)
229 NULL,
NULL, &suspend_stats_operations);
238 #ifdef CONFIG_PM_SLEEP_DEBUG
250 return sprintf(buf,
"%d\n", pm_print_times_enabled);
255 const char *buf,
size_t n)
259 if (kstrtoul(buf, 10, &val))
265 pm_print_times_enabled = !!
val;
271 static inline void pm_print_times_init(
void)
276 static inline void pm_print_times_init(
void) {}
295 #ifdef CONFIG_SUSPEND
303 #ifdef CONFIG_HIBERNATION
304 s +=
sprintf(s,
"%s\n",
"disk");
315 #ifdef CONFIG_SUSPEND
317 const char *
const *
s;
323 len = p ? p - buf :
n;
326 if (len == 4 && !
strncmp(buf,
"disk", len))
329 #ifdef CONFIG_SUSPEND
339 const char *buf,
size_t n)
353 state = decode_state(buf, n);
354 if (state < PM_SUSPEND_MAX)
356 else if (state == PM_SUSPEND_MAX)
363 return error ? error :
n;
368 #ifdef CONFIG_PM_SLEEP
409 const char *buf,
size_t n)
424 if (
sscanf(buf,
"%u", &val) == 1) {
436 #ifdef CONFIG_PM_AUTOSLEEP
446 #ifdef CONFIG_SUSPEND
447 if (state < PM_SUSPEND_MAX)
451 #ifdef CONFIG_HIBERNATION
460 const char *buf,
size_t n)
470 return error ? error :
n;
476 #ifdef CONFIG_PM_WAKELOCKS
486 const char *buf,
size_t n)
489 return error ? error :
n;
503 const char *buf,
size_t n)
506 return error ? error :
n;
514 #ifdef CONFIG_PM_TRACE
515 int pm_trace_enabled;
520 return sprintf(buf,
"%d\n", pm_trace_enabled);
525 const char *buf,
size_t n)
529 if (
sscanf(buf,
"%d", &val) == 1) {
530 pm_trace_enabled = !!
val;
547 const char *buf,
size_t n)
558 #ifdef CONFIG_PM_TRACE
560 &pm_trace_dev_match_attr.attr,
562 #ifdef CONFIG_PM_SLEEP
564 &wakeup_count_attr.attr,
565 #ifdef CONFIG_PM_AUTOSLEEP
566 &autosleep_attr.attr,
568 #ifdef CONFIG_PM_WAKELOCKS
569 &wake_lock_attr.attr,
570 &wake_unlock_attr.attr,
572 #ifdef CONFIG_PM_DEBUG
575 #ifdef CONFIG_PM_SLEEP_DEBUG
576 &pm_print_times_attr.attr,
586 #ifdef CONFIG_PM_RUNTIME
590 static int __init pm_start_workqueue(
void)
594 return pm_wq ? 0 : -
ENOMEM;
597 static inline int pm_start_workqueue(
void) {
return 0; }
600 static int __init pm_init(
void)
602 int error = pm_start_workqueue();
613 pm_print_times_init();