drm/i915: batch submit seqno off-by-one.
[linux-2.6/linux-2.6-openrd.git] / kernel / power / hibernate.c
blob04b3a83d686f63e430723e2a3e26a1fc3d3e0601
1 /*
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@suse.cz>
7 * Copyright (c) 2009 Rafael J. Wysocki, Novell Inc.
9 * This file is released under the GPLv2.
12 #include <linux/suspend.h>
13 #include <linux/syscalls.h>
14 #include <linux/reboot.h>
15 #include <linux/string.h>
16 #include <linux/device.h>
17 #include <linux/kmod.h>
18 #include <linux/delay.h>
19 #include <linux/fs.h>
20 #include <linux/mount.h>
21 #include <linux/pm.h>
22 #include <linux/console.h>
23 #include <linux/cpu.h>
24 #include <linux/freezer.h>
25 #include <scsi/scsi_scan.h>
26 #include <asm/suspend.h>
28 #include "power.h"
31 static int noresume = 0;
32 static char resume_file[256] = CONFIG_PM_STD_PARTITION;
33 dev_t swsusp_resume_device;
34 sector_t swsusp_resume_block;
36 enum {
37 HIBERNATION_INVALID,
38 HIBERNATION_PLATFORM,
39 HIBERNATION_TEST,
40 HIBERNATION_TESTPROC,
41 HIBERNATION_SHUTDOWN,
42 HIBERNATION_REBOOT,
43 /* keep last */
44 __HIBERNATION_AFTER_LAST
46 #define HIBERNATION_MAX (__HIBERNATION_AFTER_LAST-1)
47 #define HIBERNATION_FIRST (HIBERNATION_INVALID + 1)
49 static int hibernation_mode = HIBERNATION_SHUTDOWN;
51 static struct platform_hibernation_ops *hibernation_ops;
53 /**
54 * hibernation_set_ops - set the global hibernate operations
55 * @ops: the hibernation operations to use in subsequent hibernation transitions
58 void hibernation_set_ops(struct platform_hibernation_ops *ops)
60 if (ops && !(ops->begin && ops->end && ops->pre_snapshot
61 && ops->prepare && ops->finish && ops->enter && ops->pre_restore
62 && ops->restore_cleanup)) {
63 WARN_ON(1);
64 return;
66 mutex_lock(&pm_mutex);
67 hibernation_ops = ops;
68 if (ops)
69 hibernation_mode = HIBERNATION_PLATFORM;
70 else if (hibernation_mode == HIBERNATION_PLATFORM)
71 hibernation_mode = HIBERNATION_SHUTDOWN;
73 mutex_unlock(&pm_mutex);
76 static bool entering_platform_hibernation;
78 bool system_entering_hibernation(void)
80 return entering_platform_hibernation;
82 EXPORT_SYMBOL(system_entering_hibernation);
84 #ifdef CONFIG_PM_DEBUG
85 static void hibernation_debug_sleep(void)
87 printk(KERN_INFO "hibernation debug: Waiting for 5 seconds.\n");
88 mdelay(5000);
91 static int hibernation_testmode(int mode)
93 if (hibernation_mode == mode) {
94 hibernation_debug_sleep();
95 return 1;
97 return 0;
100 static int hibernation_test(int level)
102 if (pm_test_level == level) {
103 hibernation_debug_sleep();
104 return 1;
106 return 0;
108 #else /* !CONFIG_PM_DEBUG */
109 static int hibernation_testmode(int mode) { return 0; }
110 static int hibernation_test(int level) { return 0; }
111 #endif /* !CONFIG_PM_DEBUG */
114 * platform_begin - tell the platform driver that we're starting
115 * hibernation
118 static int platform_begin(int platform_mode)
120 return (platform_mode && hibernation_ops) ?
121 hibernation_ops->begin() : 0;
125 * platform_end - tell the platform driver that we've entered the
126 * working state
129 static void platform_end(int platform_mode)
131 if (platform_mode && hibernation_ops)
132 hibernation_ops->end();
136 * platform_pre_snapshot - prepare the machine for hibernation using the
137 * platform driver if so configured and return an error code if it fails
140 static int platform_pre_snapshot(int platform_mode)
142 return (platform_mode && hibernation_ops) ?
143 hibernation_ops->pre_snapshot() : 0;
147 * platform_leave - prepare the machine for switching to the normal mode
148 * of operation using the platform driver (called with interrupts disabled)
151 static void platform_leave(int platform_mode)
153 if (platform_mode && hibernation_ops)
154 hibernation_ops->leave();
158 * platform_finish - switch the machine to the normal mode of operation
159 * using the platform driver (must be called after platform_prepare())
162 static void platform_finish(int platform_mode)
164 if (platform_mode && hibernation_ops)
165 hibernation_ops->finish();
169 * platform_pre_restore - prepare the platform for the restoration from a
170 * hibernation image. If the restore fails after this function has been
171 * called, platform_restore_cleanup() must be called.
174 static int platform_pre_restore(int platform_mode)
176 return (platform_mode && hibernation_ops) ?
177 hibernation_ops->pre_restore() : 0;
181 * platform_restore_cleanup - switch the platform to the normal mode of
182 * operation after a failing restore. If platform_pre_restore() has been
183 * called before the failing restore, this function must be called too,
184 * regardless of the result of platform_pre_restore().
187 static void platform_restore_cleanup(int platform_mode)
189 if (platform_mode && hibernation_ops)
190 hibernation_ops->restore_cleanup();
194 * platform_recover - recover the platform from a failure to suspend
195 * devices.
198 static void platform_recover(int platform_mode)
200 if (platform_mode && hibernation_ops && hibernation_ops->recover)
201 hibernation_ops->recover();
205 * create_image - freeze devices that need to be frozen with interrupts
206 * off, create the hibernation image and thaw those devices. Control
207 * reappears in this routine after a restore.
210 static int create_image(int platform_mode)
212 int error;
214 error = arch_prepare_suspend();
215 if (error)
216 return error;
218 /* At this point, dpm_suspend_start() has been called, but *not*
219 * dpm_suspend_noirq(). We *must* call dpm_suspend_noirq() now.
220 * Otherwise, drivers for some devices (e.g. interrupt controllers)
221 * become desynchronized with the actual state of the hardware
222 * at resume time, and evil weirdness ensues.
224 error = dpm_suspend_noirq(PMSG_FREEZE);
225 if (error) {
226 printk(KERN_ERR "PM: Some devices failed to power down, "
227 "aborting hibernation\n");
228 return error;
231 error = platform_pre_snapshot(platform_mode);
232 if (error || hibernation_test(TEST_PLATFORM))
233 goto Platform_finish;
235 error = disable_nonboot_cpus();
236 if (error || hibernation_test(TEST_CPUS)
237 || hibernation_testmode(HIBERNATION_TEST))
238 goto Enable_cpus;
240 local_irq_disable();
242 error = sysdev_suspend(PMSG_FREEZE);
243 if (error) {
244 printk(KERN_ERR "PM: Some system devices failed to power down, "
245 "aborting hibernation\n");
246 goto Enable_irqs;
249 if (hibernation_test(TEST_CORE))
250 goto Power_up;
252 in_suspend = 1;
253 save_processor_state();
254 error = swsusp_arch_suspend();
255 if (error)
256 printk(KERN_ERR "PM: Error %d creating hibernation image\n",
257 error);
258 /* Restore control flow magically appears here */
259 restore_processor_state();
260 if (!in_suspend)
261 platform_leave(platform_mode);
263 Power_up:
264 sysdev_resume();
265 /* NOTE: dpm_resume_noirq() is just a resume() for devices
266 * that suspended with irqs off ... no overall powerup.
269 Enable_irqs:
270 local_irq_enable();
272 Enable_cpus:
273 enable_nonboot_cpus();
275 Platform_finish:
276 platform_finish(platform_mode);
278 dpm_resume_noirq(in_suspend ?
279 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE);
281 return error;
285 * hibernation_snapshot - quiesce devices and create the hibernation
286 * snapshot image.
287 * @platform_mode - if set, use the platform driver, if available, to
288 * prepare the platform firmware for the power transition.
290 * Must be called with pm_mutex held
293 int hibernation_snapshot(int platform_mode)
295 int error;
297 error = platform_begin(platform_mode);
298 if (error)
299 return error;
301 /* Preallocate image memory before shutting down devices. */
302 error = hibernate_preallocate_memory();
303 if (error)
304 goto Close;
306 suspend_console();
307 error = dpm_suspend_start(PMSG_FREEZE);
308 if (error)
309 goto Recover_platform;
311 if (hibernation_test(TEST_DEVICES))
312 goto Recover_platform;
314 error = create_image(platform_mode);
315 /* Control returns here after successful restore */
317 Resume_devices:
318 /* We may need to release the preallocated image pages here. */
319 if (error || !in_suspend)
320 swsusp_free();
322 dpm_resume_end(in_suspend ?
323 (error ? PMSG_RECOVER : PMSG_THAW) : PMSG_RESTORE);
324 resume_console();
325 Close:
326 platform_end(platform_mode);
327 return error;
329 Recover_platform:
330 platform_recover(platform_mode);
331 goto Resume_devices;
335 * resume_target_kernel - prepare devices that need to be suspended with
336 * interrupts off, restore the contents of highmem that have not been
337 * restored yet from the image and run the low level code that will restore
338 * the remaining contents of memory and switch to the just restored target
339 * kernel.
342 static int resume_target_kernel(bool platform_mode)
344 int error;
346 error = dpm_suspend_noirq(PMSG_QUIESCE);
347 if (error) {
348 printk(KERN_ERR "PM: Some devices failed to power down, "
349 "aborting resume\n");
350 return error;
353 error = platform_pre_restore(platform_mode);
354 if (error)
355 goto Cleanup;
357 error = disable_nonboot_cpus();
358 if (error)
359 goto Enable_cpus;
361 local_irq_disable();
363 error = sysdev_suspend(PMSG_QUIESCE);
364 if (error)
365 goto Enable_irqs;
367 /* We'll ignore saved state, but this gets preempt count (etc) right */
368 save_processor_state();
369 error = restore_highmem();
370 if (!error) {
371 error = swsusp_arch_resume();
373 * The code below is only ever reached in case of a failure.
374 * Otherwise execution continues at place where
375 * swsusp_arch_suspend() was called
377 BUG_ON(!error);
378 /* This call to restore_highmem() undos the previous one */
379 restore_highmem();
382 * The only reason why swsusp_arch_resume() can fail is memory being
383 * very tight, so we have to free it as soon as we can to avoid
384 * subsequent failures
386 swsusp_free();
387 restore_processor_state();
388 touch_softlockup_watchdog();
390 sysdev_resume();
392 Enable_irqs:
393 local_irq_enable();
395 Enable_cpus:
396 enable_nonboot_cpus();
398 Cleanup:
399 platform_restore_cleanup(platform_mode);
401 dpm_resume_noirq(PMSG_RECOVER);
403 return error;
407 * hibernation_restore - quiesce devices and restore the hibernation
408 * snapshot image. If successful, control returns in hibernation_snaphot()
409 * @platform_mode - if set, use the platform driver, if available, to
410 * prepare the platform firmware for the transition.
412 * Must be called with pm_mutex held
415 int hibernation_restore(int platform_mode)
417 int error;
419 pm_prepare_console();
420 suspend_console();
421 error = dpm_suspend_start(PMSG_QUIESCE);
422 if (!error) {
423 error = resume_target_kernel(platform_mode);
424 dpm_resume_end(PMSG_RECOVER);
426 resume_console();
427 pm_restore_console();
428 return error;
432 * hibernation_platform_enter - enter the hibernation state using the
433 * platform driver (if available)
436 int hibernation_platform_enter(void)
438 int error;
440 if (!hibernation_ops)
441 return -ENOSYS;
444 * We have cancelled the power transition by running
445 * hibernation_ops->finish() before saving the image, so we should let
446 * the firmware know that we're going to enter the sleep state after all
448 error = hibernation_ops->begin();
449 if (error)
450 goto Close;
452 entering_platform_hibernation = true;
453 suspend_console();
454 error = dpm_suspend_start(PMSG_HIBERNATE);
455 if (error) {
456 if (hibernation_ops->recover)
457 hibernation_ops->recover();
458 goto Resume_devices;
461 error = dpm_suspend_noirq(PMSG_HIBERNATE);
462 if (error)
463 goto Resume_devices;
465 error = hibernation_ops->prepare();
466 if (error)
467 goto Platform_finish;
469 error = disable_nonboot_cpus();
470 if (error)
471 goto Platform_finish;
473 local_irq_disable();
474 sysdev_suspend(PMSG_HIBERNATE);
475 hibernation_ops->enter();
476 /* We should never get here */
477 while (1);
480 * We don't need to reenable the nonboot CPUs or resume consoles, since
481 * the system is going to be halted anyway.
483 Platform_finish:
484 hibernation_ops->finish();
486 dpm_suspend_noirq(PMSG_RESTORE);
488 Resume_devices:
489 entering_platform_hibernation = false;
490 dpm_resume_end(PMSG_RESTORE);
491 resume_console();
493 Close:
494 hibernation_ops->end();
496 return error;
500 * power_down - Shut the machine down for hibernation.
502 * Use the platform driver, if configured so; otherwise try
503 * to power off or reboot.
506 static void power_down(void)
508 switch (hibernation_mode) {
509 case HIBERNATION_TEST:
510 case HIBERNATION_TESTPROC:
511 break;
512 case HIBERNATION_REBOOT:
513 kernel_restart(NULL);
514 break;
515 case HIBERNATION_PLATFORM:
516 hibernation_platform_enter();
517 case HIBERNATION_SHUTDOWN:
518 kernel_power_off();
519 break;
521 kernel_halt();
523 * Valid image is on the disk, if we continue we risk serious data
524 * corruption after resume.
526 printk(KERN_CRIT "PM: Please power down manually\n");
527 while(1);
530 static int prepare_processes(void)
532 int error = 0;
534 if (freeze_processes()) {
535 error = -EBUSY;
536 thaw_processes();
538 return error;
542 * hibernate - The granpappy of the built-in hibernation management
545 int hibernate(void)
547 int error;
549 mutex_lock(&pm_mutex);
550 /* The snapshot device should not be opened while we're running */
551 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
552 error = -EBUSY;
553 goto Unlock;
556 pm_prepare_console();
557 error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
558 if (error)
559 goto Exit;
561 error = usermodehelper_disable();
562 if (error)
563 goto Exit;
565 /* Allocate memory management structures */
566 error = create_basic_memory_bitmaps();
567 if (error)
568 goto Exit;
570 printk(KERN_INFO "PM: Syncing filesystems ... ");
571 sys_sync();
572 printk("done.\n");
574 error = prepare_processes();
575 if (error)
576 goto Finish;
578 if (hibernation_test(TEST_FREEZER))
579 goto Thaw;
581 if (hibernation_testmode(HIBERNATION_TESTPROC))
582 goto Thaw;
584 error = hibernation_snapshot(hibernation_mode == HIBERNATION_PLATFORM);
585 if (error)
586 goto Thaw;
588 if (in_suspend) {
589 unsigned int flags = 0;
591 if (hibernation_mode == HIBERNATION_PLATFORM)
592 flags |= SF_PLATFORM_MODE;
593 pr_debug("PM: writing image.\n");
594 error = swsusp_write(flags);
595 swsusp_free();
596 if (!error)
597 power_down();
598 } else {
599 pr_debug("PM: Image restored successfully.\n");
602 Thaw:
603 thaw_processes();
604 Finish:
605 free_basic_memory_bitmaps();
606 usermodehelper_enable();
607 Exit:
608 pm_notifier_call_chain(PM_POST_HIBERNATION);
609 pm_restore_console();
610 atomic_inc(&snapshot_device_available);
611 Unlock:
612 mutex_unlock(&pm_mutex);
613 return error;
618 * software_resume - Resume from a saved image.
620 * Called as a late_initcall (so all devices are discovered and
621 * initialized), we call swsusp to see if we have a saved image or not.
622 * If so, we quiesce devices, the restore the saved image. We will
623 * return above (in hibernate() ) if everything goes well.
624 * Otherwise, we fail gracefully and return to the normally
625 * scheduled program.
629 static int software_resume(void)
631 int error;
632 unsigned int flags;
635 * If the user said "noresume".. bail out early.
637 if (noresume)
638 return 0;
641 * name_to_dev_t() below takes a sysfs buffer mutex when sysfs
642 * is configured into the kernel. Since the regular hibernate
643 * trigger path is via sysfs which takes a buffer mutex before
644 * calling hibernate functions (which take pm_mutex) this can
645 * cause lockdep to complain about a possible ABBA deadlock
646 * which cannot happen since we're in the boot code here and
647 * sysfs can't be invoked yet. Therefore, we use a subclass
648 * here to avoid lockdep complaining.
650 mutex_lock_nested(&pm_mutex, SINGLE_DEPTH_NESTING);
652 if (swsusp_resume_device)
653 goto Check_image;
655 if (!strlen(resume_file)) {
656 error = -ENOENT;
657 goto Unlock;
660 pr_debug("PM: Checking image partition %s\n", resume_file);
662 /* Check if the device is there */
663 swsusp_resume_device = name_to_dev_t(resume_file);
664 if (!swsusp_resume_device) {
666 * Some device discovery might still be in progress; we need
667 * to wait for this to finish.
669 wait_for_device_probe();
671 * We can't depend on SCSI devices being available after loading
672 * one of their modules until scsi_complete_async_scans() is
673 * called and the resume device usually is a SCSI one.
675 scsi_complete_async_scans();
677 swsusp_resume_device = name_to_dev_t(resume_file);
678 if (!swsusp_resume_device) {
679 error = -ENODEV;
680 goto Unlock;
684 Check_image:
685 pr_debug("PM: Resume from partition %d:%d\n",
686 MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device));
688 pr_debug("PM: Checking hibernation image.\n");
689 error = swsusp_check();
690 if (error)
691 goto Unlock;
693 /* The snapshot device should not be opened while we're running */
694 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
695 error = -EBUSY;
696 goto Unlock;
699 pm_prepare_console();
700 error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
701 if (error)
702 goto Finish;
704 error = usermodehelper_disable();
705 if (error)
706 goto Finish;
708 error = create_basic_memory_bitmaps();
709 if (error)
710 goto Finish;
712 pr_debug("PM: Preparing processes for restore.\n");
713 error = prepare_processes();
714 if (error) {
715 swsusp_close(FMODE_READ);
716 goto Done;
719 pr_debug("PM: Reading hibernation image.\n");
721 error = swsusp_read(&flags);
722 if (!error)
723 hibernation_restore(flags & SF_PLATFORM_MODE);
725 printk(KERN_ERR "PM: Restore failed, recovering.\n");
726 swsusp_free();
727 thaw_processes();
728 Done:
729 free_basic_memory_bitmaps();
730 usermodehelper_enable();
731 Finish:
732 pm_notifier_call_chain(PM_POST_RESTORE);
733 pm_restore_console();
734 atomic_inc(&snapshot_device_available);
735 /* For success case, the suspend path will release the lock */
736 Unlock:
737 mutex_unlock(&pm_mutex);
738 pr_debug("PM: Resume from disk failed.\n");
739 return error;
742 late_initcall(software_resume);
745 static const char * const hibernation_modes[] = {
746 [HIBERNATION_PLATFORM] = "platform",
747 [HIBERNATION_SHUTDOWN] = "shutdown",
748 [HIBERNATION_REBOOT] = "reboot",
749 [HIBERNATION_TEST] = "test",
750 [HIBERNATION_TESTPROC] = "testproc",
754 * disk - Control hibernation mode
756 * Suspend-to-disk can be handled in several ways. We have a few options
757 * for putting the system to sleep - using the platform driver (e.g. ACPI
758 * or other hibernation_ops), powering off the system or rebooting the
759 * system (for testing) as well as the two test modes.
761 * The system can support 'platform', and that is known a priori (and
762 * encoded by the presence of hibernation_ops). However, the user may
763 * choose 'shutdown' or 'reboot' as alternatives, as well as one fo the
764 * test modes, 'test' or 'testproc'.
766 * show() will display what the mode is currently set to.
767 * store() will accept one of
769 * 'platform'
770 * 'shutdown'
771 * 'reboot'
772 * 'test'
773 * 'testproc'
775 * It will only change to 'platform' if the system
776 * supports it (as determined by having hibernation_ops).
779 static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
780 char *buf)
782 int i;
783 char *start = buf;
785 for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
786 if (!hibernation_modes[i])
787 continue;
788 switch (i) {
789 case HIBERNATION_SHUTDOWN:
790 case HIBERNATION_REBOOT:
791 case HIBERNATION_TEST:
792 case HIBERNATION_TESTPROC:
793 break;
794 case HIBERNATION_PLATFORM:
795 if (hibernation_ops)
796 break;
797 /* not a valid mode, continue with loop */
798 continue;
800 if (i == hibernation_mode)
801 buf += sprintf(buf, "[%s] ", hibernation_modes[i]);
802 else
803 buf += sprintf(buf, "%s ", hibernation_modes[i]);
805 buf += sprintf(buf, "\n");
806 return buf-start;
810 static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
811 const char *buf, size_t n)
813 int error = 0;
814 int i;
815 int len;
816 char *p;
817 int mode = HIBERNATION_INVALID;
819 p = memchr(buf, '\n', n);
820 len = p ? p - buf : n;
822 mutex_lock(&pm_mutex);
823 for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
824 if (len == strlen(hibernation_modes[i])
825 && !strncmp(buf, hibernation_modes[i], len)) {
826 mode = i;
827 break;
830 if (mode != HIBERNATION_INVALID) {
831 switch (mode) {
832 case HIBERNATION_SHUTDOWN:
833 case HIBERNATION_REBOOT:
834 case HIBERNATION_TEST:
835 case HIBERNATION_TESTPROC:
836 hibernation_mode = mode;
837 break;
838 case HIBERNATION_PLATFORM:
839 if (hibernation_ops)
840 hibernation_mode = mode;
841 else
842 error = -EINVAL;
844 } else
845 error = -EINVAL;
847 if (!error)
848 pr_debug("PM: Hibernation mode set to '%s'\n",
849 hibernation_modes[mode]);
850 mutex_unlock(&pm_mutex);
851 return error ? error : n;
854 power_attr(disk);
856 static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
857 char *buf)
859 return sprintf(buf,"%d:%d\n", MAJOR(swsusp_resume_device),
860 MINOR(swsusp_resume_device));
863 static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
864 const char *buf, size_t n)
866 unsigned int maj, min;
867 dev_t res;
868 int ret = -EINVAL;
870 if (sscanf(buf, "%u:%u", &maj, &min) != 2)
871 goto out;
873 res = MKDEV(maj,min);
874 if (maj != MAJOR(res) || min != MINOR(res))
875 goto out;
877 mutex_lock(&pm_mutex);
878 swsusp_resume_device = res;
879 mutex_unlock(&pm_mutex);
880 printk(KERN_INFO "PM: Starting manual resume from disk\n");
881 noresume = 0;
882 software_resume();
883 ret = n;
884 out:
885 return ret;
888 power_attr(resume);
890 static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
891 char *buf)
893 return sprintf(buf, "%lu\n", image_size);
896 static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
897 const char *buf, size_t n)
899 unsigned long size;
901 if (sscanf(buf, "%lu", &size) == 1) {
902 image_size = size;
903 return n;
906 return -EINVAL;
909 power_attr(image_size);
911 static struct attribute * g[] = {
912 &disk_attr.attr,
913 &resume_attr.attr,
914 &image_size_attr.attr,
915 NULL,
919 static struct attribute_group attr_group = {
920 .attrs = g,
924 static int __init pm_disk_init(void)
926 return sysfs_create_group(power_kobj, &attr_group);
929 core_initcall(pm_disk_init);
932 static int __init resume_setup(char *str)
934 if (noresume)
935 return 1;
937 strncpy( resume_file, str, 255 );
938 return 1;
941 static int __init resume_offset_setup(char *str)
943 unsigned long long offset;
945 if (noresume)
946 return 1;
948 if (sscanf(str, "%llu", &offset) == 1)
949 swsusp_resume_block = offset;
951 return 1;
954 static int __init noresume_setup(char *str)
956 noresume = 1;
957 return 1;
960 __setup("noresume", noresume_setup);
961 __setup("resume_offset=", resume_offset_setup);
962 __setup("resume=", resume_setup);