diff options
Diffstat (limited to 'kernel/power/main.c')
| -rw-r--r-- | kernel/power/main.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index 428f8a034e96..f458238109cc 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
| @@ -235,6 +235,47 @@ late_initcall(pm_debugfs_init); | |||
| 235 | 235 | ||
| 236 | #endif /* CONFIG_PM_SLEEP */ | 236 | #endif /* CONFIG_PM_SLEEP */ |
| 237 | 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 | */ | ||
| 245 | bool pm_print_times_enabled; | ||
| 246 | |||
| 247 | static 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 | |||
| 253 | static 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 | |||
| 269 | power_attr(pm_print_times); | ||
| 270 | |||
| 271 | static inline void pm_print_times_init(void) | ||
| 272 | { | ||
| 273 | pm_print_times_enabled = !!initcall_debug; | ||
| 274 | } | ||
| 275 | #else /* !CONFIG_PP_SLEEP_DEBUG */ | ||
| 276 | static inline void pm_print_times_init(void) {} | ||
| 277 | #endif /* CONFIG_PM_SLEEP_DEBUG */ | ||
| 278 | |||
| 238 | struct kobject *power_kobj; | 279 | struct kobject *power_kobj; |
| 239 | 280 | ||
| 240 | /** | 281 | /** |
| @@ -531,6 +572,9 @@ static struct attribute * g[] = { | |||
| 531 | #ifdef CONFIG_PM_DEBUG | 572 | #ifdef CONFIG_PM_DEBUG |
| 532 | &pm_test_attr.attr, | 573 | &pm_test_attr.attr, |
| 533 | #endif | 574 | #endif |
| 575 | #ifdef CONFIG_PM_SLEEP_DEBUG | ||
| 576 | &pm_print_times_attr.attr, | ||
| 577 | #endif | ||
| 534 | #endif | 578 | #endif |
| 535 | NULL, | 579 | NULL, |
| 536 | }; | 580 | }; |
| @@ -566,6 +610,7 @@ static int __init pm_init(void) | |||
| 566 | error = sysfs_create_group(power_kobj, &attr_group); | 610 | error = sysfs_create_group(power_kobj, &attr_group); |
| 567 | if (error) | 611 | if (error) |
| 568 | return error; | 612 | return error; |
| 613 | pm_print_times_init(); | ||
| 569 | return pm_autosleep_init(); | 614 | return pm_autosleep_init(); |
| 570 | } | 615 | } |
| 571 | 616 | ||
