Commit c1e09b2c authored by Andrew Morton's avatar Andrew Morton Committed by Patrick Mochel

[PATCH] Small cleanups for swsusp

From: Pavel Machek <pavel@ucw.cz>

Here are some small cleanups: whitespace fixes, added severity level,
shuffle messages and kill unneccessary strings, add some statics and fixed
misleading comments.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
parent 06793e87
...@@ -31,7 +31,7 @@ ENTRY(swsusp_arch_resume) ...@@ -31,7 +31,7 @@ ENTRY(swsusp_arch_resume)
movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx
movl %ecx,%cr3 movl %ecx,%cr3
movl pagedir_nosave,%ebx movl pagedir_nosave, %ebx
xorl %eax, %eax xorl %eax, %eax
xorl %edx, %edx xorl %edx, %edx
.p2align 4,,7 .p2align 4,,7
......
...@@ -65,7 +65,7 @@ static int power_down(u32 mode) ...@@ -65,7 +65,7 @@ static int power_down(u32 mode)
machine_halt(); machine_halt();
/* Valid image is on the disk, if we continue we risk serious data corruption /* Valid image is on the disk, if we continue we risk serious data corruption
after resume. */ after resume. */
printk("Please power me down manually\n"); printk(KERN_CRIT "Please power me down manually\n");
while(1); while(1);
return 0; return 0;
} }
......
...@@ -99,8 +99,8 @@ unsigned int nr_copy_pages __nosavedata = 0; ...@@ -99,8 +99,8 @@ unsigned int nr_copy_pages __nosavedata = 0;
MMU hardware. MMU hardware.
*/ */
suspend_pagedir_t *pagedir_nosave __nosavedata = NULL; suspend_pagedir_t *pagedir_nosave __nosavedata = NULL;
suspend_pagedir_t *pagedir_save; static suspend_pagedir_t *pagedir_save;
int pagedir_order __nosavedata = 0; static int pagedir_order __nosavedata = 0;
#define SWSUSP_SIG "S1SUSPEND" #define SWSUSP_SIG "S1SUSPEND"
...@@ -119,9 +119,6 @@ struct swsusp_info swsusp_info; ...@@ -119,9 +119,6 @@ struct swsusp_info swsusp_info;
*/ */
#define PAGES_FOR_IO 512 #define PAGES_FOR_IO 512
static const char name_suspend[] = "Suspend Machine: ";
static const char name_resume[] = "Resume Machine: ";
/* /*
* Saving part... * Saving part...
*/ */
...@@ -141,10 +138,10 @@ static int mark_swapfiles(swp_entry_t prev) ...@@ -141,10 +138,10 @@ static int mark_swapfiles(swp_entry_t prev)
rw_swap_page_sync(READ, rw_swap_page_sync(READ,
swp_entry(root_swap, 0), swp_entry(root_swap, 0),
virt_to_page((unsigned long)&swsusp_header)); virt_to_page((unsigned long)&swsusp_header));
if (!memcmp("SWAP-SPACE",swsusp_header.sig,10) || if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
!memcmp("SWAPSPACE2",swsusp_header.sig,10)) { !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
memcpy(swsusp_header.orig_sig,swsusp_header.sig,10); memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
memcpy(swsusp_header.sig,SWSUSP_SIG,10); memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
swsusp_header.swsusp_info = prev; swsusp_header.swsusp_info = prev;
error = rw_swap_page_sync(WRITE, error = rw_swap_page_sync(WRITE,
swp_entry(root_swap, 0), swp_entry(root_swap, 0),
...@@ -265,9 +262,10 @@ static int write_page(unsigned long addr, swp_entry_t * loc) ...@@ -265,9 +262,10 @@ static int write_page(unsigned long addr, swp_entry_t * loc)
/** /**
* free_data - Free the swap entries used by the saved image. * data_free - Free the swap entries used by the saved image.
* *
* Walk the list of used swap entries and free each one. * Walk the list of used swap entries and free each one.
* This is only used for cleanup when suspend fails.
*/ */
static void data_free(void) static void data_free(void)
...@@ -287,7 +285,7 @@ static void data_free(void) ...@@ -287,7 +285,7 @@ static void data_free(void)
/** /**
* write_data - Write saved image to swap. * data_write - Write saved image to swap.
* *
* Walk the list of pages in the image and sync each one to swap. * Walk the list of pages in the image and sync each one to swap.
*/ */
...@@ -351,15 +349,16 @@ static int close_swap(void) ...@@ -351,15 +349,16 @@ static int close_swap(void)
} }
/** /**
* free_pagedir - Free pages used by the page directory. * free_pagedir_entries - Free pages used by the page directory.
*
* This is used during suspend for error recovery.
*/ */
static void free_pagedir_entries(void) static void free_pagedir_entries(void)
{ {
int num = swsusp_info.pagedir_pages;
int i; int i;
for (i = 0; i < num; i++) for (i = 0; i < swsusp_info.pagedir_pages; i++)
swap_free(swsusp_info.pagedir[i]); swap_free(swsusp_info.pagedir[i]);
} }
...@@ -379,7 +378,7 @@ static int write_pagedir(void) ...@@ -379,7 +378,7 @@ static int write_pagedir(void)
swsusp_info.pagedir_pages = n; swsusp_info.pagedir_pages = n;
printk( "Writing pagedir (%d pages)\n", n); printk( "Writing pagedir (%d pages)\n", n);
for (i = 0; i < n && !error; i++, addr += PAGE_SIZE) for (i = 0; i < n && !error; i++, addr += PAGE_SIZE)
error = write_page(addr,&swsusp_info.pagedir[i]); error = write_page(addr, &swsusp_info.pagedir[i]);
return error; return error;
} }
...@@ -668,8 +667,8 @@ static void calc_order(void) ...@@ -668,8 +667,8 @@ static void calc_order(void)
/** /**
* alloc_pagedir - Allocate the page directory. * alloc_pagedir - Allocate the page directory.
* *
* First, determine exactly how many contiguous pages we need, * First, determine exactly how many contiguous pages we need and
* allocate them, then mark each 'unsavable'. * allocate them.
*/ */
static int alloc_pagedir(void) static int alloc_pagedir(void)
...@@ -721,7 +720,7 @@ static int alloc_image_pages(void) ...@@ -721,7 +720,7 @@ static int alloc_image_pages(void)
static int enough_free_mem(void) static int enough_free_mem(void)
{ {
if(nr_free_pages() < (nr_copy_pages + PAGES_FOR_IO)) { if (nr_free_pages() < (nr_copy_pages + PAGES_FOR_IO)) {
pr_debug("swsusp: Not enough free pages: Have %d\n", pr_debug("swsusp: Not enough free pages: Have %d\n",
nr_free_pages()); nr_free_pages());
return 0; return 0;
...@@ -757,7 +756,7 @@ static int swsusp_alloc(void) ...@@ -757,7 +756,7 @@ static int swsusp_alloc(void)
int error; int error;
pr_debug("suspend: (pages needed: %d + %d free: %d)\n", pr_debug("suspend: (pages needed: %d + %d free: %d)\n",
nr_copy_pages,PAGES_FOR_IO,nr_free_pages()); nr_copy_pages, PAGES_FOR_IO, nr_free_pages());
pagedir_nosave = NULL; pagedir_nosave = NULL;
if (!enough_free_mem()) if (!enough_free_mem())
...@@ -788,7 +787,7 @@ int suspend_prepare_image(void) ...@@ -788,7 +787,7 @@ int suspend_prepare_image(void)
pr_debug("swsusp: critical section: \n"); pr_debug("swsusp: critical section: \n");
if (save_highmem()) { if (save_highmem()) {
printk(KERN_CRIT "%sNot enough free pages for highmem\n", name_suspend); printk(KERN_CRIT "Suspend machine: Not enough free pages for highmem\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -900,8 +899,8 @@ static int __init does_collide_order(suspend_pagedir_t *pagedir, unsigned long a ...@@ -900,8 +899,8 @@ static int __init does_collide_order(suspend_pagedir_t *pagedir, unsigned long a
int i; int i;
unsigned long addre = addr + (PAGE_SIZE<<order); unsigned long addre = addr + (PAGE_SIZE<<order);
for(i=0; i < nr_copy_pages; i++) for (i=0; i < nr_copy_pages; i++)
if((pagedir+i)->orig_address >= addr && if ((pagedir+i)->orig_address >= addr &&
(pagedir+i)->orig_address < addre) (pagedir+i)->orig_address < addre)
return 1; return 1;
...@@ -1023,7 +1022,7 @@ static int submit(int rw, pgoff_t page_off, void * page) ...@@ -1023,7 +1022,7 @@ static int submit(int rw, pgoff_t page_off, void * page)
int error = 0; int error = 0;
struct bio * bio; struct bio * bio;
bio = bio_alloc(GFP_ATOMIC,1); bio = bio_alloc(GFP_ATOMIC, 1);
if (!bio) if (!bio)
return -ENOMEM; return -ENOMEM;
bio->bi_sector = page_off * (PAGE_SIZE >> 9); bio->bi_sector = page_off * (PAGE_SIZE >> 9);
...@@ -1049,12 +1048,12 @@ static int submit(int rw, pgoff_t page_off, void * page) ...@@ -1049,12 +1048,12 @@ static int submit(int rw, pgoff_t page_off, void * page)
int bio_read_page(pgoff_t page_off, void * page) int bio_read_page(pgoff_t page_off, void * page)
{ {
return submit(READ,page_off,page); return submit(READ, page_off, page);
} }
int bio_write_page(pgoff_t page_off, void * page) int bio_write_page(pgoff_t page_off, void * page)
{ {
return submit(WRITE,page_off,page); return submit(WRITE, page_off, page);
} }
/* /*
...@@ -1104,16 +1103,16 @@ static int __init check_sig(void) ...@@ -1104,16 +1103,16 @@ static int __init check_sig(void)
{ {
int error; int error;
memset(&swsusp_header,0,sizeof(swsusp_header)); memset(&swsusp_header, 0, sizeof(swsusp_header));
if ((error = bio_read_page(0,&swsusp_header))) if ((error = bio_read_page(0, &swsusp_header)))
return error; return error;
if (!memcmp(SWSUSP_SIG,swsusp_header.sig,10)) { if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
memcpy(swsusp_header.sig,swsusp_header.orig_sig,10); memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
/* /*
* Reset swap signature now. * Reset swap signature now.
*/ */
error = bio_write_page(0,&swsusp_header); error = bio_write_page(0, &swsusp_header);
} else { } else {
pr_debug(KERN_ERR "swsusp: Invalid partition type.\n"); pr_debug(KERN_ERR "swsusp: Invalid partition type.\n");
return -EINVAL; return -EINVAL;
...@@ -1187,7 +1186,7 @@ static int __init read_pagedir(void) ...@@ -1187,7 +1186,7 @@ static int __init read_pagedir(void)
error = -EFAULT; error = -EFAULT;
} }
if (error) if (error)
free_pages((unsigned long)pagedir_nosave,pagedir_order); free_pages((unsigned long)pagedir_nosave, pagedir_order);
return error; return error;
} }
......
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