/** * software_resume - Resume from a saved image. * * Called as a late_initcall (so all devices are discovered and * initialized), we call swsusp to see if we have a saved image or not. * If so, we quiesce devices, then restore the saved image. We will * return above (in pm_suspend_disk() ) if everything goes well. * Otherwise, we fail gracefully and return to the normally * scheduled program. * */ static int __init software_resume(void) { if (num_online_cpus() > 1) { printk(KERN_WARNING "Software Suspend has malfunctioning SMP support. Disabled :(\n"); return -EINVAL; } /* We enable the possibility of machine suspend */ software_suspend_enabled = 1; if (!resume_status) return 0; printk( "%s", name_resume ); if (resume_status == NORESUME) { if(resume_file[0]) read_suspend_image(resume_file, 1); printk( "disabled\n" ); return 0; } MDELAY(1000); if (pm_prepare_console()) printk("swsusp: Can't allocate a console... proceeding\n"); if (!resume_file[0] && resume_status == RESUME_SPECIFIED) { printk( "suspension device unspecified\n" ); return -EINVAL; } printk( "resuming from %s\n", resume_file); if (read_suspend_image(resume_file, 0)) goto read_failure; do_magic(1); panic("This never returns"); read_failure: pm_restore_console(); return 0; }
int __init pmdisk_read(void) { int error; if (!strlen(resume_file)) return -ENOENT; resume_device = name_to_dev_t(resume_file); pr_debug("pmdisk: Resume From Partition: %s\n", resume_file); resume_bdev = open_by_devnum(resume_device, FMODE_READ); if (!IS_ERR(resume_bdev)) { set_blocksize(resume_bdev, PAGE_SIZE); error = read_suspend_image(); blkdev_put(resume_bdev); } else error = PTR_ERR(resume_bdev); if (!error) pr_debug("Reading resume file was successful\n"); else pr_debug("pmdisk: Error %d resuming\n", error); return error; }