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) ...@@ -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) static int __init read_suspend_image(void)
{ {
extern int swsusp_data_read(void);
int error = 0; int error = 0;
if ((error = check_sig())) if ((error = check_sig()))
...@@ -420,15 +397,10 @@ static int __init read_suspend_image(void) ...@@ -420,15 +397,10 @@ static int __init read_suspend_image(void)
return error; return error;
if ((error = read_pagedir())) if ((error = read_pagedir()))
return error; return error;
if ((error = swsusp_pagedir_relocate())) if ((error = swsusp_data_read())) {
goto FreePagedir;
if ((error = read_image_data()))
goto FreePagedir;
Done:
return error;
FreePagedir:
free_pages((unsigned long)pagedir_nosave,pagedir_order); free_pages((unsigned long)pagedir_nosave,pagedir_order);
goto Done; }
return error;
} }
......
...@@ -18,9 +18,6 @@ static inline int pm_suspend_disk(void) ...@@ -18,9 +18,6 @@ static inline int pm_suspend_disk(void)
return -EPERM; return -EPERM;
} }
#endif #endif
extern int swsusp_pagedir_relocate(void);
extern struct semaphore pm_sem; extern struct semaphore pm_sem;
#define power_attr(_name) \ #define power_attr(_name) \
static struct subsys_attribute _name##_attr = { \ static struct subsys_attribute _name##_attr = { \
......
...@@ -1041,7 +1041,7 @@ static int __init check_pagedir(void) ...@@ -1041,7 +1041,7 @@ static int __init check_pagedir(void)
return 0; 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), * We have to avoid recursion (not to overflow kernel stack),
...@@ -1198,6 +1198,34 @@ int bio_write_page(pgoff_t page_off, void * page) ...@@ -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); extern dev_t __init name_to_dev_t(const char *line);
static int __init __read_suspend_image(int noresume) static int __init __read_suspend_image(int noresume)
...@@ -1205,6 +1233,7 @@ static int __init __read_suspend_image(int noresume) ...@@ -1205,6 +1233,7 @@ static int __init __read_suspend_image(int noresume)
union diskpage *cur; union diskpage *cur;
swp_entry_t next; swp_entry_t next;
int i, nr_pgdir_pages; int i, nr_pgdir_pages;
int error;
cur = (union diskpage *)get_zeroed_page(GFP_ATOMIC); cur = (union diskpage *)get_zeroed_page(GFP_ATOMIC);
if (!cur) if (!cur)
...@@ -1272,19 +1301,8 @@ static int __init __read_suspend_image(int noresume) ...@@ -1272,19 +1301,8 @@ static int __init __read_suspend_image(int noresume)
} }
BUG_ON (next.val); BUG_ON (next.val);
if (swsusp_pagedir_relocate()) error = swsusp_data_read();
return -ENOMEM; if (!error)
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" ); printk( "|\n" );
return 0; 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