main.c (4b7760ba0dd3319f66886ab2335a0fbecdbc808a) main.c (b2df1d4f8b95d9d1e3f064cef02fc5c5116b05cf)
1/*
2 * kernel/power/main.c - PM subsystem core functionality.
3 *
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Lab
6 *
7 * This file is released under the GPLv2
8 *

--- 118 unchanged lines hidden (view full) ---

127 }
128
129 unlock_system_sleep();
130
131 return error ? error : n;
132}
133
134power_attr(pm_test);
1/*
2 * kernel/power/main.c - PM subsystem core functionality.
3 *
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Lab
6 *
7 * This file is released under the GPLv2
8 *

--- 118 unchanged lines hidden (view full) ---

127 }
128
129 unlock_system_sleep();
130
131 return error ? error : n;
132}
133
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 */
168
169#ifdef CONFIG_DEBUG_FS
170static char *suspend_step_name(enum suspend_stat_step step)
171{
172 switch (step) {
173 case SUSPEND_FREEZE:
174 return "freeze";

--- 87 unchanged lines hidden (view full) ---

262 return 0;
263}
264
265late_initcall(pm_debugfs_init);
266#endif /* CONFIG_DEBUG_FS */
267
268#endif /* CONFIG_PM_SLEEP */
269
135#endif /* CONFIG_PM_DEBUG */
136
137#ifdef CONFIG_DEBUG_FS
138static char *suspend_step_name(enum suspend_stat_step step)
139{
140 switch (step) {
141 case SUSPEND_FREEZE:
142 return "freeze";

--- 87 unchanged lines hidden (view full) ---

230 return 0;
231}
232
233late_initcall(pm_debugfs_init);
234#endif /* CONFIG_DEBUG_FS */
235
236#endif /* CONFIG_PM_SLEEP */
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;
271
272/**
273 * state - control system power state.
274 *
275 * show() returns what states are supported, which is hard-coded to
276 * 'standby' (Power-On Suspend), 'mem' (Suspend-to-RAM), and
277 * 'disk' (Suspend-to-Disk).

--- 279 unchanged lines hidden (view full) ---

557 &autosleep_attr.attr,
558#endif
559#ifdef CONFIG_PM_WAKELOCKS
560 &wake_lock_attr.attr,
561 &wake_unlock_attr.attr,
562#endif
563#ifdef CONFIG_PM_DEBUG
564 &pm_test_attr.attr,
279struct kobject *power_kobj;
280
281/**
282 * state - control system power state.
283 *
284 * show() returns what states are supported, which is hard-coded to
285 * 'standby' (Power-On Suspend), 'mem' (Suspend-to-RAM), and
286 * 'disk' (Suspend-to-Disk).

--- 279 unchanged lines hidden (view full) ---

566 &autosleep_attr.attr,
567#endif
568#ifdef CONFIG_PM_WAKELOCKS
569 &wake_lock_attr.attr,
570 &wake_unlock_attr.attr,
571#endif
572#ifdef CONFIG_PM_DEBUG
573 &pm_test_attr.attr,
574#endif
575#ifdef CONFIG_PM_SLEEP_DEBUG
565 &pm_print_times_attr.attr,
566#endif
567#endif
568 NULL,
569};
570
571static struct attribute_group attr_group = {
572 .attrs = g,

--- 21 unchanged lines hidden (view full) ---

594 hibernate_image_size_init();
595 hibernate_reserved_size_init();
596 power_kobj = kobject_create_and_add("power", NULL);
597 if (!power_kobj)
598 return -ENOMEM;
599 error = sysfs_create_group(power_kobj, &attr_group);
600 if (error)
601 return error;
576 &pm_print_times_attr.attr,
577#endif
578#endif
579 NULL,
580};
581
582static struct attribute_group attr_group = {
583 .attrs = g,

--- 21 unchanged lines hidden (view full) ---

605 hibernate_image_size_init();
606 hibernate_reserved_size_init();
607 power_kobj = kobject_create_and_add("power", NULL);
608 if (!power_kobj)
609 return -ENOMEM;
610 error = sysfs_create_group(power_kobj, &attr_group);
611 if (error)
612 return error;
613 pm_print_times_init();
602 return pm_autosleep_init();
603}
604
605core_initcall(pm_init);
614 return pm_autosleep_init();
615}
616
617core_initcall(pm_init);