2 * kernel/power/hibernate.c - Hibernation (a.k.a suspend-to-disk) support.
4 * Copyright (c) 2003 Patrick Mochel
5 * Copyright (c) 2003 Open Source Development Lab
6 * Copyright (c) 2004 Pavel Machek <pavel@ucw.cz>
7 * Copyright (c) 2009 Rafael J. Wysocki, Novell Inc.
8 * Copyright (C) 2012 Bojan Smojver <bojan@rexursive.com>
10 * This file is released under the GPLv2.
13 #include <linux/export.h>
14 #include <linux/suspend.h>
15 #include <linux/syscalls.h>
16 #include <linux/reboot.h>
17 #include <linux/string.h>
18 #include <linux/device.h>
19 #include <linux/async.h>
20 #include <linux/delay.h>
22 #include <linux/mount.h>
24 #include <linux/console.h>
25 #include <linux/cpu.h>
26 #include <linux/freezer.h>
27 #include <linux/gfp.h>
28 #include <linux/syscore_ops.h>
29 #include <linux/ctype.h>
30 #include <linux/genhd.h>
31 #include <trace/events/power.h>
36 static int nocompress
;
38 static int resume_wait
;
39 static unsigned int resume_delay
;
40 static char resume_file
[256] = CONFIG_PM_STD_PARTITION
;
41 dev_t swsusp_resume_device
;
42 sector_t swsusp_resume_block
;
43 __visible
int in_suspend __nosavedata
;
54 __HIBERNATION_AFTER_LAST
56 #define HIBERNATION_MAX (__HIBERNATION_AFTER_LAST-1)
57 #define HIBERNATION_FIRST (HIBERNATION_INVALID + 1)
59 static int hibernation_mode
= HIBERNATION_SHUTDOWN
;
61 bool freezer_test_done
;
63 static const struct platform_hibernation_ops
*hibernation_ops
;
66 * hibernation_set_ops - Set the global hibernate operations.
67 * @ops: Hibernation operations to use in subsequent hibernation transitions.
69 void hibernation_set_ops(const struct platform_hibernation_ops
*ops
)
71 if (ops
&& !(ops
->begin
&& ops
->end
&& ops
->pre_snapshot
72 && ops
->prepare
&& ops
->finish
&& ops
->enter
&& ops
->pre_restore
73 && ops
->restore_cleanup
&& ops
->leave
)) {
78 hibernation_ops
= ops
;
80 hibernation_mode
= HIBERNATION_PLATFORM
;
81 else if (hibernation_mode
== HIBERNATION_PLATFORM
)
82 hibernation_mode
= HIBERNATION_SHUTDOWN
;
84 unlock_system_sleep();
86 EXPORT_SYMBOL_GPL(hibernation_set_ops
);
88 static bool entering_platform_hibernation
;
90 bool system_entering_hibernation(void)
92 return entering_platform_hibernation
;
94 EXPORT_SYMBOL(system_entering_hibernation
);
96 #ifdef CONFIG_PM_DEBUG
97 static void hibernation_debug_sleep(void)
99 printk(KERN_INFO
"hibernation debug: Waiting for 5 seconds.\n");
103 static int hibernation_test(int level
)
105 if (pm_test_level
== level
) {
106 hibernation_debug_sleep();
111 #else /* !CONFIG_PM_DEBUG */
112 static int hibernation_test(int level
) { return 0; }
113 #endif /* !CONFIG_PM_DEBUG */
116 * platform_begin - Call platform to start hibernation.
117 * @platform_mode: Whether or not to use the platform driver.
119 static int platform_begin(int platform_mode
)
121 return (platform_mode
&& hibernation_ops
) ?
122 hibernation_ops
->begin() : 0;
126 * platform_end - Call platform to finish transition to the working state.
127 * @platform_mode: Whether or not to use the platform driver.
129 static void platform_end(int platform_mode
)
131 if (platform_mode
&& hibernation_ops
)
132 hibernation_ops
->end();
136 * platform_pre_snapshot - Call platform to prepare the machine for hibernation.
137 * @platform_mode: Whether or not to use the platform driver.
139 * Use the platform driver to prepare the system for creating a hibernate image,
140 * if so configured, and return an error code if that fails.
143 static int platform_pre_snapshot(int platform_mode
)
145 return (platform_mode
&& hibernation_ops
) ?
146 hibernation_ops
->pre_snapshot() : 0;
150 * platform_leave - Call platform to prepare a transition to the working state.
151 * @platform_mode: Whether or not to use the platform driver.
153 * Use the platform driver prepare to prepare the machine for switching to the
154 * normal mode of operation.
156 * This routine is called on one CPU with interrupts disabled.
158 static void platform_leave(int platform_mode
)
160 if (platform_mode
&& hibernation_ops
)
161 hibernation_ops
->leave();
165 * platform_finish - Call platform to switch the system to the working state.
166 * @platform_mode: Whether or not to use the platform driver.
168 * Use the platform driver to switch the machine to the normal mode of
171 * This routine must be called after platform_prepare().
173 static void platform_finish(int platform_mode
)
175 if (platform_mode
&& hibernation_ops
)
176 hibernation_ops
->finish();
180 * platform_pre_restore - Prepare for hibernate image restoration.
181 * @platform_mode: Whether or not to use the platform driver.
183 * Use the platform driver to prepare the system for resume from a hibernation
186 * If the restore fails after this function has been called,
187 * platform_restore_cleanup() must be called.
189 static int platform_pre_restore(int platform_mode
)
191 return (platform_mode
&& hibernation_ops
) ?
192 hibernation_ops
->pre_restore() : 0;
196 * platform_restore_cleanup - Switch to the working state after failing restore.
197 * @platform_mode: Whether or not to use the platform driver.
199 * Use the platform driver to switch the system to the normal mode of operation
200 * after a failing restore.
202 * If platform_pre_restore() has been called before the failing restore, this
203 * function must be called too, regardless of the result of
204 * platform_pre_restore().
206 static void platform_restore_cleanup(int platform_mode
)
208 if (platform_mode
&& hibernation_ops
)
209 hibernation_ops
->restore_cleanup();
213 * platform_recover - Recover from a failure to suspend devices.
214 * @platform_mode: Whether or not to use the platform driver.
216 static void platform_recover(int platform_mode
)
218 if (platform_mode
&& hibernation_ops
&& hibernation_ops
->recover
)
219 hibernation_ops
->recover();
223 * swsusp_show_speed - Print time elapsed between two events during hibernation.
224 * @start: Starting event.
225 * @stop: Final event.
226 * @nr_pages: Number of memory pages processed between @start and @stop.
227 * @msg: Additional diagnostic message to print.
229 void swsusp_show_speed(struct timeval
*start
, struct timeval
*stop
,
230 unsigned nr_pages
, char *msg
)
232 u64 elapsed_centisecs64
;
233 unsigned int centisecs
;
237 elapsed_centisecs64
= timeval_to_ns(stop
) - timeval_to_ns(start
);
239 * If "(s64)elapsed_centisecs64 < 0", it will print long elapsed time,
240 * it is obvious enough for what went wrong.
242 do_div(elapsed_centisecs64
, NSEC_PER_SEC
/ 100);
243 centisecs
= elapsed_centisecs64
;
245 centisecs
= 1; /* avoid div-by-zero */
246 k
= nr_pages
* (PAGE_SIZE
/ 1024);
247 kps
= (k
* 100) / centisecs
;
248 printk(KERN_INFO
"PM: %s %u kbytes in %u.%02u seconds (%u.%02u MB/s)\n",
250 centisecs
/ 100, centisecs
% 100,
251 kps
/ 1000, (kps
% 1000) / 10);
255 * create_image - Create a hibernation image.
256 * @platform_mode: Whether or not to use the platform driver.
258 * Execute device drivers' "late" and "noirq" freeze callbacks, create a
259 * hibernation image and run the drivers' "noirq" and "early" thaw callbacks.
261 * Control reappears in this routine after the subsequent restore.
263 static int create_image(int platform_mode
)
267 error
= dpm_suspend_end(PMSG_FREEZE
);
269 printk(KERN_ERR
"PM: Some devices failed to power down, "
270 "aborting hibernation\n");
274 error
= platform_pre_snapshot(platform_mode
);
275 if (error
|| hibernation_test(TEST_PLATFORM
))
276 goto Platform_finish
;
278 error
= disable_nonboot_cpus();
279 if (error
|| hibernation_test(TEST_CPUS
))
284 error
= syscore_suspend();
286 printk(KERN_ERR
"PM: Some system devices failed to power down, "
287 "aborting hibernation\n");
291 if (hibernation_test(TEST_CORE
) || pm_wakeup_pending())
295 save_processor_state();
296 trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE
, true);
297 error
= swsusp_arch_suspend();
298 trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE
, false);
300 printk(KERN_ERR
"PM: Error %d creating hibernation image\n",
302 /* Restore control flow magically appears here */
303 restore_processor_state();
305 events_check_enabled
= false;
307 platform_leave(platform_mode
);
316 enable_nonboot_cpus();
319 platform_finish(platform_mode
);
321 dpm_resume_start(in_suspend
?
322 (error
? PMSG_RECOVER
: PMSG_THAW
) : PMSG_RESTORE
);
328 * hibernation_snapshot - Quiesce devices and create a hibernation image.
329 * @platform_mode: If set, use platform driver to prepare for the transition.
331 * This routine must be called with pm_mutex held.
333 int hibernation_snapshot(int platform_mode
)
338 error
= platform_begin(platform_mode
);
342 /* Preallocate image memory before shutting down devices. */
343 error
= hibernate_preallocate_memory();
347 error
= freeze_kernel_threads();
351 if (hibernation_test(TEST_FREEZER
)) {
354 * Indicate to the caller that we are returning due to a
355 * successful freezer test.
357 freezer_test_done
= true;
361 error
= dpm_prepare(PMSG_FREEZE
);
363 dpm_complete(PMSG_RECOVER
);
369 pm_restrict_gfp_mask();
371 error
= dpm_suspend(PMSG_FREEZE
);
373 if (error
|| hibernation_test(TEST_DEVICES
))
374 platform_recover(platform_mode
);
376 error
= create_image(platform_mode
);
379 * In the case that we call create_image() above, the control
380 * returns here (1) after the image has been created or the
381 * image creation has failed and (2) after a successful restore.
384 /* We may need to release the preallocated image pages here. */
385 if (error
|| !in_suspend
)
388 msg
= in_suspend
? (error
? PMSG_RECOVER
: PMSG_THAW
) : PMSG_RESTORE
;
391 if (error
|| !in_suspend
)
392 pm_restore_gfp_mask();
399 platform_end(platform_mode
);
403 thaw_kernel_threads();
410 * resume_target_kernel - Restore system state from a hibernation image.
411 * @platform_mode: Whether or not to use the platform driver.
413 * Execute device drivers' "noirq" and "late" freeze callbacks, restore the
414 * contents of highmem that have not been restored yet from the image and run
415 * the low-level code that will restore the remaining contents of memory and
416 * switch to the just restored target kernel.
418 static int resume_target_kernel(bool platform_mode
)
422 error
= dpm_suspend_end(PMSG_QUIESCE
);
424 printk(KERN_ERR
"PM: Some devices failed to power down, "
425 "aborting resume\n");
429 error
= platform_pre_restore(platform_mode
);
433 error
= disable_nonboot_cpus();
439 error
= syscore_suspend();
443 save_processor_state();
444 error
= restore_highmem();
446 error
= swsusp_arch_resume();
448 * The code below is only ever reached in case of a failure.
449 * Otherwise, execution continues at the place where
450 * swsusp_arch_suspend() was called.
454 * This call to restore_highmem() reverts the changes made by
460 * The only reason why swsusp_arch_resume() can fail is memory being
461 * very tight, so we have to free it as soon as we can to avoid
462 * subsequent failures.
465 restore_processor_state();
466 touch_softlockup_watchdog();
474 enable_nonboot_cpus();
477 platform_restore_cleanup(platform_mode
);
479 dpm_resume_start(PMSG_RECOVER
);
485 * hibernation_restore - Quiesce devices and restore from a hibernation image.
486 * @platform_mode: If set, use platform driver to prepare for the transition.
488 * This routine must be called with pm_mutex held. If it is successful, control
489 * reappears in the restored target kernel in hibernation_snapshot().
491 int hibernation_restore(int platform_mode
)
495 pm_prepare_console();
498 pm_restrict_gfp_mask();
499 error
= dpm_suspend_start(PMSG_QUIESCE
);
501 error
= resume_target_kernel(platform_mode
);
502 dpm_resume_end(PMSG_RECOVER
);
504 pm_restore_gfp_mask();
507 pm_restore_console();
512 * hibernation_platform_enter - Power off the system using the platform driver.
514 int hibernation_platform_enter(void)
518 if (!hibernation_ops
)
522 * We have cancelled the power transition by running
523 * hibernation_ops->finish() before saving the image, so we should let
524 * the firmware know that we're going to enter the sleep state after all
526 error
= hibernation_ops
->begin();
530 entering_platform_hibernation
= true;
533 error
= dpm_suspend_start(PMSG_HIBERNATE
);
535 if (hibernation_ops
->recover
)
536 hibernation_ops
->recover();
540 error
= dpm_suspend_end(PMSG_HIBERNATE
);
544 error
= hibernation_ops
->prepare();
546 goto Platform_finish
;
548 error
= disable_nonboot_cpus();
550 goto Platform_finish
;
554 if (pm_wakeup_pending()) {
559 hibernation_ops
->enter();
560 /* We should never get here */
566 enable_nonboot_cpus();
569 hibernation_ops
->finish();
571 dpm_resume_start(PMSG_RESTORE
);
574 entering_platform_hibernation
= false;
575 dpm_resume_end(PMSG_RESTORE
);
580 hibernation_ops
->end();
586 * power_down - Shut the machine down for hibernation.
588 * Use the platform driver, if configured, to put the system into the sleep
589 * state corresponding to hibernation, or try to power it off or reboot,
590 * depending on the value of hibernation_mode.
592 static void power_down(void)
594 #ifdef CONFIG_SUSPEND
598 switch (hibernation_mode
) {
599 case HIBERNATION_REBOOT
:
600 kernel_restart(NULL
);
602 case HIBERNATION_PLATFORM
:
603 hibernation_platform_enter();
604 case HIBERNATION_SHUTDOWN
:
608 #ifdef CONFIG_SUSPEND
609 case HIBERNATION_SUSPEND
:
610 error
= suspend_devices_and_enter(PM_SUSPEND_MEM
);
613 hibernation_mode
= HIBERNATION_PLATFORM
;
615 hibernation_mode
= HIBERNATION_SHUTDOWN
;
619 * Restore swap signature.
621 error
= swsusp_unmark();
623 printk(KERN_ERR
"PM: Swap will be unusable! "
630 * Valid image is on the disk, if we continue we risk serious data
631 * corruption after resume.
633 printk(KERN_CRIT
"PM: Please power down manually\n");
639 * hibernate - Carry out system hibernation, including saving the image.
646 /* The snapshot device should not be opened while we're running */
647 if (!atomic_add_unless(&snapshot_device_available
, -1, 0)) {
652 pm_prepare_console();
653 error
= pm_notifier_call_chain(PM_HIBERNATION_PREPARE
);
657 printk(KERN_INFO
"PM: Syncing filesystems ... ");
661 error
= freeze_processes();
665 lock_device_hotplug();
666 /* Allocate memory management structures */
667 error
= create_basic_memory_bitmaps();
671 error
= hibernation_snapshot(hibernation_mode
== HIBERNATION_PLATFORM
);
672 if (error
|| freezer_test_done
)
676 unsigned int flags
= 0;
678 if (hibernation_mode
== HIBERNATION_PLATFORM
)
679 flags
|= SF_PLATFORM_MODE
;
681 flags
|= SF_NOCOMPRESS_MODE
;
683 flags
|= SF_CRC32_MODE
;
685 pr_debug("PM: writing image.\n");
686 error
= swsusp_write(flags
);
691 pm_restore_gfp_mask();
693 pr_debug("PM: Image restored successfully.\n");
697 free_basic_memory_bitmaps();
699 unlock_device_hotplug();
702 /* Don't bother checking whether freezer_test_done is true */
703 freezer_test_done
= false;
705 pm_notifier_call_chain(PM_POST_HIBERNATION
);
706 pm_restore_console();
707 atomic_inc(&snapshot_device_available
);
709 unlock_system_sleep();
715 * software_resume - Resume from a saved hibernation image.
717 * This routine is called as a late initcall, when all devices have been
718 * discovered and initialized already.
720 * The image reading code is called to see if there is a hibernation image
721 * available for reading. If that is the case, devices are quiesced and the
722 * contents of memory is restored from the saved image.
724 * If this is successful, control reappears in the restored target kernel in
725 * hibernation_snaphot() which returns to hibernate(). Otherwise, the routine
726 * attempts to recover gracefully and make the kernel return to the normal mode
729 static int software_resume(void)
735 * If the user said "noresume".. bail out early.
741 * name_to_dev_t() below takes a sysfs buffer mutex when sysfs
742 * is configured into the kernel. Since the regular hibernate
743 * trigger path is via sysfs which takes a buffer mutex before
744 * calling hibernate functions (which take pm_mutex) this can
745 * cause lockdep to complain about a possible ABBA deadlock
746 * which cannot happen since we're in the boot code here and
747 * sysfs can't be invoked yet. Therefore, we use a subclass
748 * here to avoid lockdep complaining.
750 mutex_lock_nested(&pm_mutex
, SINGLE_DEPTH_NESTING
);
752 if (swsusp_resume_device
)
755 if (!strlen(resume_file
)) {
760 pr_debug("PM: Checking hibernation image partition %s\n", resume_file
);
763 printk(KERN_INFO
"Waiting %dsec before reading resume device...\n",
765 ssleep(resume_delay
);
768 /* Check if the device is there */
769 swsusp_resume_device
= name_to_dev_t(resume_file
);
772 * name_to_dev_t is ineffective to verify parition if resume_file is in
773 * integer format. (e.g. major:minor)
775 if (isdigit(resume_file
[0]) && resume_wait
) {
777 while (!get_gendisk(swsusp_resume_device
, &partno
))
781 if (!swsusp_resume_device
) {
783 * Some device discovery might still be in progress; we need
784 * to wait for this to finish.
786 wait_for_device_probe();
789 while ((swsusp_resume_device
= name_to_dev_t(resume_file
)) == 0)
791 async_synchronize_full();
794 swsusp_resume_device
= name_to_dev_t(resume_file
);
795 if (!swsusp_resume_device
) {
802 pr_debug("PM: Hibernation image partition %d:%d present\n",
803 MAJOR(swsusp_resume_device
), MINOR(swsusp_resume_device
));
805 pr_debug("PM: Looking for hibernation image.\n");
806 error
= swsusp_check();
810 /* The snapshot device should not be opened while we're running */
811 if (!atomic_add_unless(&snapshot_device_available
, -1, 0)) {
813 swsusp_close(FMODE_READ
);
817 pm_prepare_console();
818 error
= pm_notifier_call_chain(PM_RESTORE_PREPARE
);
822 pr_debug("PM: Preparing processes for restore.\n");
823 error
= freeze_processes();
827 pr_debug("PM: Loading hibernation image.\n");
829 lock_device_hotplug();
830 error
= create_basic_memory_bitmaps();
834 error
= swsusp_read(&flags
);
835 swsusp_close(FMODE_READ
);
837 hibernation_restore(flags
& SF_PLATFORM_MODE
);
839 printk(KERN_ERR
"PM: Failed to load hibernation image, recovering.\n");
841 free_basic_memory_bitmaps();
843 unlock_device_hotplug();
846 pm_notifier_call_chain(PM_POST_RESTORE
);
847 pm_restore_console();
848 atomic_inc(&snapshot_device_available
);
849 /* For success case, the suspend path will release the lock */
851 mutex_unlock(&pm_mutex
);
852 pr_debug("PM: Hibernation image not present or could not be loaded.\n");
855 swsusp_close(FMODE_READ
);
859 late_initcall_sync(software_resume
);
862 static const char * const hibernation_modes
[] = {
863 [HIBERNATION_PLATFORM
] = "platform",
864 [HIBERNATION_SHUTDOWN
] = "shutdown",
865 [HIBERNATION_REBOOT
] = "reboot",
866 #ifdef CONFIG_SUSPEND
867 [HIBERNATION_SUSPEND
] = "suspend",
872 * /sys/power/disk - Control hibernation mode.
874 * Hibernation can be handled in several ways. There are a few different ways
875 * to put the system into the sleep state: using the platform driver (e.g. ACPI
876 * or other hibernation_ops), powering it off or rebooting it (for testing
879 * The sysfs file /sys/power/disk provides an interface for selecting the
880 * hibernation mode to use. Reading from this file causes the available modes
881 * to be printed. There are 3 modes that can be supported:
887 * If a platform hibernation driver is in use, 'platform' will be supported
888 * and will be used by default. Otherwise, 'shutdown' will be used by default.
889 * The selected option (i.e. the one corresponding to the current value of
890 * hibernation_mode) is enclosed by a square bracket.
892 * To select a given hibernation mode it is necessary to write the mode's
893 * string representation (as returned by reading from /sys/power/disk) back
894 * into /sys/power/disk.
897 static ssize_t
disk_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
903 for (i
= HIBERNATION_FIRST
; i
<= HIBERNATION_MAX
; i
++) {
904 if (!hibernation_modes
[i
])
907 case HIBERNATION_SHUTDOWN
:
908 case HIBERNATION_REBOOT
:
909 #ifdef CONFIG_SUSPEND
910 case HIBERNATION_SUSPEND
:
913 case HIBERNATION_PLATFORM
:
916 /* not a valid mode, continue with loop */
919 if (i
== hibernation_mode
)
920 buf
+= sprintf(buf
, "[%s] ", hibernation_modes
[i
]);
922 buf
+= sprintf(buf
, "%s ", hibernation_modes
[i
]);
924 buf
+= sprintf(buf
, "\n");
928 static ssize_t
disk_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
929 const char *buf
, size_t n
)
935 int mode
= HIBERNATION_INVALID
;
937 p
= memchr(buf
, '\n', n
);
938 len
= p
? p
- buf
: n
;
941 for (i
= HIBERNATION_FIRST
; i
<= HIBERNATION_MAX
; i
++) {
942 if (len
== strlen(hibernation_modes
[i
])
943 && !strncmp(buf
, hibernation_modes
[i
], len
)) {
948 if (mode
!= HIBERNATION_INVALID
) {
950 case HIBERNATION_SHUTDOWN
:
951 case HIBERNATION_REBOOT
:
952 #ifdef CONFIG_SUSPEND
953 case HIBERNATION_SUSPEND
:
955 hibernation_mode
= mode
;
957 case HIBERNATION_PLATFORM
:
959 hibernation_mode
= mode
;
967 pr_debug("PM: Hibernation mode set to '%s'\n",
968 hibernation_modes
[mode
]);
969 unlock_system_sleep();
970 return error
? error
: n
;
975 static ssize_t
resume_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
978 return sprintf(buf
,"%d:%d\n", MAJOR(swsusp_resume_device
),
979 MINOR(swsusp_resume_device
));
982 static ssize_t
resume_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
983 const char *buf
, size_t n
)
989 if (len
&& buf
[len
-1] == '\n')
991 name
= kstrndup(buf
, len
, GFP_KERNEL
);
995 res
= name_to_dev_t(name
);
1000 lock_system_sleep();
1001 swsusp_resume_device
= res
;
1002 unlock_system_sleep();
1003 printk(KERN_INFO
"PM: Starting manual resume from disk\n");
1011 static ssize_t
image_size_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
1014 return sprintf(buf
, "%lu\n", image_size
);
1017 static ssize_t
image_size_store(struct kobject
*kobj
, struct kobj_attribute
*attr
,
1018 const char *buf
, size_t n
)
1022 if (sscanf(buf
, "%lu", &size
) == 1) {
1030 power_attr(image_size
);
1032 static ssize_t
reserved_size_show(struct kobject
*kobj
,
1033 struct kobj_attribute
*attr
, char *buf
)
1035 return sprintf(buf
, "%lu\n", reserved_size
);
1038 static ssize_t
reserved_size_store(struct kobject
*kobj
,
1039 struct kobj_attribute
*attr
,
1040 const char *buf
, size_t n
)
1044 if (sscanf(buf
, "%lu", &size
) == 1) {
1045 reserved_size
= size
;
1052 power_attr(reserved_size
);
1054 static struct attribute
* g
[] = {
1057 &image_size_attr
.attr
,
1058 &reserved_size_attr
.attr
,
1063 static struct attribute_group attr_group
= {
1068 static int __init
pm_disk_init(void)
1070 return sysfs_create_group(power_kobj
, &attr_group
);
1073 core_initcall(pm_disk_init
);
1076 static int __init
resume_setup(char *str
)
1081 strncpy( resume_file
, str
, 255 );
1085 static int __init
resume_offset_setup(char *str
)
1087 unsigned long long offset
;
1092 if (sscanf(str
, "%llu", &offset
) == 1)
1093 swsusp_resume_block
= offset
;
1098 static int __init
hibernate_setup(char *str
)
1100 if (!strncmp(str
, "noresume", 8))
1102 else if (!strncmp(str
, "nocompress", 10))
1107 static int __init
noresume_setup(char *str
)
1113 static int __init
resumewait_setup(char *str
)
1119 static int __init
resumedelay_setup(char *str
)
1121 int rc
= kstrtouint(str
, 0, &resume_delay
);
1128 __setup("noresume", noresume_setup
);
1129 __setup("resume_offset=", resume_offset_setup
);
1130 __setup("resume=", resume_setup
);
1131 __setup("hibernate=", hibernate_setup
);
1132 __setup("resumewait", resumewait_setup
);
1133 __setup("resumedelay=", resumedelay_setup
);