diff options
Diffstat (limited to 'kernel/power')
| -rw-r--r-- | kernel/power/Kconfig | 4 | ||||
| -rw-r--r-- | kernel/power/main.c | 76 | 
2 files changed, 46 insertions, 34 deletions
| diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig index 8f9b4eb974e0..a70518c9d82f 100644 --- a/kernel/power/Kconfig +++ b/kernel/power/Kconfig @@ -175,7 +175,7 @@ config PM_TEST_SUSPEND  	You probably want to have your system's RTC driver statically  	linked, ensuring that it's available when this test runs. -config CAN_PM_TRACE +config PM_SLEEP_DEBUG  	def_bool y  	depends on PM_DEBUG && PM_SLEEP @@ -196,7 +196,7 @@ config PM_TRACE  config PM_TRACE_RTC  	bool "Suspend/resume event tracing" -	depends on CAN_PM_TRACE +	depends on PM_SLEEP_DEBUG  	depends on X86  	select PM_TRACE  	---help--- 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,  }  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 @@ -267,6 +235,47 @@ late_initcall(pm_debugfs_init);  #endif /* CONFIG_PM_SLEEP */ +#ifdef CONFIG_PM_SLEEP_DEBUG +/* + * 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. + */ +bool 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); + +static inline void pm_print_times_init(void) +{ +	pm_print_times_enabled = !!initcall_debug; +} +#else /* !CONFIG_PP_SLEEP_DEBUG */ +static inline void pm_print_times_init(void) {} +#endif /* CONFIG_PM_SLEEP_DEBUG */ +  struct kobject *power_kobj;  /** @@ -562,6 +571,8 @@ static struct attribute * g[] = {  #endif  #ifdef CONFIG_PM_DEBUG  	&pm_test_attr.attr, +#endif +#ifdef CONFIG_PM_SLEEP_DEBUG  	&pm_print_times_attr.attr,  #endif  #endif @@ -599,6 +610,7 @@ static int __init pm_init(void)  	error = sysfs_create_group(power_kobj, &attr_group);  	if (error)  		return error; +	pm_print_times_init();  	return pm_autosleep_init();  } | 
