Commit a5b568fe authored by Patrick Mochel's avatar Patrick Mochel

[Power Mgmt] Merge pmdisk and swsusp read wrappers.

- Merge pmdisk_read() and __read_suspend_image() and rename to swsusp_read()
- Fix up call in kernel/power/disk.c to call new name.
- Remove extra error checking from software_resume().
parent a65ee5aa
......@@ -25,7 +25,7 @@ extern struct pm_ops * pm_ops;
extern int swsusp_suspend(void);
extern int pmdisk_write(void);
extern int pmdisk_read(void);
extern int swsusp_read(void);
extern int swsusp_resume(void);
extern int pmdisk_free(void);
......@@ -205,7 +205,7 @@ static int pm_resume(void)
pr_debug("PM: Reading pmdisk image.\n");
if ((error = pmdisk_read()))
if ((error = swsusp_read()))
goto Done;
pr_debug("PM: Preparing system for restore.\n");
......
......@@ -35,9 +35,6 @@
/* For resume= kernel option */
static char resume_file[256] = CONFIG_PM_DISK_PARTITION;
static dev_t resume_device;
extern suspend_pagedir_t *pagedir_save;
/*
......@@ -73,14 +70,6 @@ static int suspend_save_image(void)
}
/* More restore stuff */
extern struct block_device * resume_bdev;
extern dev_t __init name_to_dev_t(const char *line);
/**
* pmdisk_write - Write saved memory image to swap.
*
......@@ -96,38 +85,6 @@ int pmdisk_write(void)
return suspend_save_image();
}
/**
* pmdisk_read - Read saved image from swap.
*/
int __init pmdisk_read(void)
{
extern int read_suspend_image(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;
}
/**
* pmdisk_free - Free memory allocated to hold snapshot.
*/
......
......@@ -1145,7 +1145,7 @@ static void wait_io(void)
}
struct block_device * resume_bdev;
static struct block_device * resume_bdev;
/**
* submit - submit BIO request.
......@@ -1331,7 +1331,7 @@ static int __init read_pagedir(void)
return error;
}
int __init read_suspend_image(void)
static int __init read_suspend_image(void)
{
int error = 0;
......@@ -1345,13 +1345,20 @@ int __init read_suspend_image(void)
return error;
}
static int __init __read_suspend_image(const char * specialfile)
/**
* pmdisk_read - Read saved image from swap.
*/
int __init swsusp_read(void)
{
int error;
char b[BDEVNAME_SIZE];
resume_device = name_to_dev_t(specialfile);
printk("Resuming from device %s\n", __bdevname(resume_device, b));
if (!strlen(resume_file))
return -ENOENT;
resume_device = name_to_dev_t(resume_file);
pr_debug("swsusp: 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);
......@@ -1359,7 +1366,11 @@ static int __init __read_suspend_image(const char * specialfile)
blkdev_put(resume_bdev);
} else
error = PTR_ERR(resume_bdev);
MDELAY(1000);
if (!error)
pr_debug("Reading resume file was successful\n");
else
pr_debug("pmdisk: Error %d resuming\n", error);
return error;
}
......@@ -1398,13 +1409,7 @@ static int __init software_resume(void)
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))
if (swsusp_read())
goto read_failure;
/* FIXME: Should we stop processes here, just to be safer? */
disable_nonboot_cpus();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment