Commit 5beeb715 authored by Patrick Mochel's avatar Patrick Mochel

[Power Mgmt] Merge pmdisk/swsusp image reading code.

- Create swsusp_data_read() and call from read_suspend_image() in both
  swsusp and pmdisk. 
- Mark swsusp_pagedir_relocate() as static again. 
parent b52d040a
......@@ -385,33 +385,10 @@ static int __init read_pagedir(void)
}
/**
* read_image_data - Read image pages from swap.
*
* You do not need to check for overlaps, check_pagedir()
* already did that.
*/
static int __init read_image_data(void)
{
struct pbe * p;
int error = 0;
int i;
printk( "Reading image data (%d pages): ", nr_copy_pages );
for(i = 0, p = pagedir_nosave; i < nr_copy_pages && !error; i++, p++) {
if (!(i%100))
printk( "." );
error = bio_read_page(swp_offset(p->swap_address),
(void *)p->address);
}
printk(" %d done.\n",i);
return error;
}
static int __init read_suspend_image(void)
{
extern int swsusp_data_read(void);
int error = 0;
if ((error = check_sig()))
......@@ -420,15 +397,10 @@ static int __init read_suspend_image(void)
return error;
if ((error = read_pagedir()))
return error;
if ((error = swsusp_pagedir_relocate()))
goto FreePagedir;
if ((error = read_image_data()))
goto FreePagedir;
Done:
if ((error = swsusp_data_read())) {
free_pages((unsigned long)pagedir_nosave,pagedir_order);
}
return error;
FreePagedir:
free_pages((unsigned long)pagedir_nosave,pagedir_order);
goto Done;
}
......
......@@ -18,9 +18,6 @@ static inline int pm_suspend_disk(void)
return -EPERM;
}
#endif
extern int swsusp_pagedir_relocate(void);
extern struct semaphore pm_sem;
#define power_attr(_name) \
static struct subsys_attribute _name##_attr = { \
......
......@@ -1041,7 +1041,7 @@ static int __init check_pagedir(void)
return 0;
}
int __init swsusp_pagedir_relocate(void)
static int __init swsusp_pagedir_relocate(void)
{
/*
* We have to avoid recursion (not to overflow kernel stack),
......@@ -1198,6 +1198,34 @@ int bio_write_page(pgoff_t page_off, void * page)
}
/**
* swsusp_read_data - Read image pages from swap.
*
* You do not need to check for overlaps, check_pagedir()
* already did that.
*/
int __init swsusp_data_read(void)
{
struct pbe * p;
int error;
int i;
if ((error = swsusp_pagedir_relocate()))
return error;
printk( "Reading image data (%d pages): ", nr_copy_pages );
for(i = 0, p = pagedir_nosave; i < nr_copy_pages && !error; i++, p++) {
if (!(i%100))
printk( "." );
error = bio_read_page(swp_offset(p->swap_address),
(void *)p->address);
}
printk(" %d done.\n",i);
return error;
}
extern dev_t __init name_to_dev_t(const char *line);
static int __init __read_suspend_image(int noresume)
......@@ -1205,6 +1233,7 @@ static int __init __read_suspend_image(int noresume)
union diskpage *cur;
swp_entry_t next;
int i, nr_pgdir_pages;
int error;
cur = (union diskpage *)get_zeroed_page(GFP_ATOMIC);
if (!cur)
......@@ -1272,20 +1301,9 @@ static int __init __read_suspend_image(int noresume)
}
BUG_ON (next.val);
if (swsusp_pagedir_relocate())
return -ENOMEM;
printk( "Reading image data (%d pages): ", nr_copy_pages );
for(i=0; i < nr_copy_pages; i++) {
swp_entry_t swap_address = (pagedir_nosave+i)->swap_address;
if (!(i%100))
printk( "." );
/* You do not need to check for overlaps...
... check_pagedir already did this work */
if (bio_read_page(swp_offset(swap_address) * PAGE_SIZE, (char *)((pagedir_nosave+i)->address)))
return -EIO;
}
printk( "|\n" );
error = swsusp_data_read();
if (!error)
printk( "|\n" );
return 0;
}
......
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