diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2006-09-26 02:32:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:49:02 -0400 |
commit | 0bcd888d64684f896ffa70c1d16a42b00753c184 (patch) | |
tree | 17c26a6d1b8236f7d4ebb8bc3475550ca961cd57 /kernel/power | |
parent | 75534b50cc658e951bcb213c2763c81e9f7b0b48 (diff) |
[PATCH] swsusp: Introduce some helpful constants
Introduce some constants that hopefully will help improve the readability of
code in kernel/power/snapshot.c.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/snapshot.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 1d276b3ae152..d0d691f976d8 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -167,6 +167,11 @@ static inline int restore_highmem(void) {return 0;} | |||
167 | * and we count them using unsafe_pages | 167 | * and we count them using unsafe_pages |
168 | */ | 168 | */ |
169 | 169 | ||
170 | #define PG_ANY 0 | ||
171 | #define PG_SAFE 1 | ||
172 | #define PG_UNSAFE_CLEAR 1 | ||
173 | #define PG_UNSAFE_KEEP 0 | ||
174 | |||
170 | static unsigned int unsafe_pages; | 175 | static unsigned int unsafe_pages; |
171 | 176 | ||
172 | static void *alloc_image_page(gfp_t gfp_mask, int safe_needed) | 177 | static void *alloc_image_page(gfp_t gfp_mask, int safe_needed) |
@@ -190,7 +195,7 @@ static void *alloc_image_page(gfp_t gfp_mask, int safe_needed) | |||
190 | 195 | ||
191 | unsigned long get_safe_page(gfp_t gfp_mask) | 196 | unsigned long get_safe_page(gfp_t gfp_mask) |
192 | { | 197 | { |
193 | return (unsigned long)alloc_image_page(gfp_mask, 1); | 198 | return (unsigned long)alloc_image_page(gfp_mask, PG_SAFE); |
194 | } | 199 | } |
195 | 200 | ||
196 | /** | 201 | /** |
@@ -381,7 +386,7 @@ static struct pbe *alloc_pagedir(unsigned int nr_pages, gfp_t gfp_mask, | |||
381 | pbe = pblist; | 386 | pbe = pblist; |
382 | for (num = PBES_PER_PAGE; num < nr_pages; num += PBES_PER_PAGE) { | 387 | for (num = PBES_PER_PAGE; num < nr_pages; num += PBES_PER_PAGE) { |
383 | if (!pbe) { | 388 | if (!pbe) { |
384 | free_pagedir(pblist, 1); | 389 | free_pagedir(pblist, PG_UNSAFE_CLEAR); |
385 | return NULL; | 390 | return NULL; |
386 | } | 391 | } |
387 | pbe += PB_PAGE_SKIP; | 392 | pbe += PB_PAGE_SKIP; |
@@ -458,12 +463,13 @@ static struct pbe *swsusp_alloc(unsigned int nr_pages) | |||
458 | { | 463 | { |
459 | struct pbe *pblist; | 464 | struct pbe *pblist; |
460 | 465 | ||
461 | if (!(pblist = alloc_pagedir(nr_pages, GFP_ATOMIC | __GFP_COLD, 0))) { | 466 | pblist = alloc_pagedir(nr_pages, GFP_ATOMIC | __GFP_COLD, PG_ANY); |
467 | if (!pblist) { | ||
462 | printk(KERN_ERR "suspend: Allocating pagedir failed.\n"); | 468 | printk(KERN_ERR "suspend: Allocating pagedir failed.\n"); |
463 | return NULL; | 469 | return NULL; |
464 | } | 470 | } |
465 | 471 | ||
466 | if (alloc_data_pages(pblist, GFP_ATOMIC | __GFP_COLD, 0)) { | 472 | if (alloc_data_pages(pblist, GFP_ATOMIC | __GFP_COLD, PG_ANY)) { |
467 | printk(KERN_ERR "suspend: Allocating image pages failed.\n"); | 473 | printk(KERN_ERR "suspend: Allocating image pages failed.\n"); |
468 | swsusp_free(); | 474 | swsusp_free(); |
469 | return NULL; | 475 | return NULL; |
@@ -575,7 +581,7 @@ int snapshot_read_next(struct snapshot_handle *handle, size_t count) | |||
575 | return 0; | 581 | return 0; |
576 | if (!buffer) { | 582 | if (!buffer) { |
577 | /* This makes the buffer be freed by swsusp_free() */ | 583 | /* This makes the buffer be freed by swsusp_free() */ |
578 | buffer = alloc_image_page(GFP_ATOMIC, 0); | 584 | buffer = alloc_image_page(GFP_ATOMIC, PG_ANY); |
579 | if (!buffer) | 585 | if (!buffer) |
580 | return -ENOMEM; | 586 | return -ENOMEM; |
581 | } | 587 | } |
@@ -688,7 +694,7 @@ static int load_header(struct snapshot_handle *handle, | |||
688 | 694 | ||
689 | error = check_header(info); | 695 | error = check_header(info); |
690 | if (!error) { | 696 | if (!error) { |
691 | pblist = alloc_pagedir(info->image_pages, GFP_ATOMIC, 0); | 697 | pblist = alloc_pagedir(info->image_pages, GFP_ATOMIC, PG_ANY); |
692 | if (!pblist) | 698 | if (!pblist) |
693 | return -ENOMEM; | 699 | return -ENOMEM; |
694 | restore_pblist = pblist; | 700 | restore_pblist = pblist; |
@@ -746,10 +752,10 @@ static int prepare_image(struct snapshot_handle *handle) | |||
746 | p = restore_pblist; | 752 | p = restore_pblist; |
747 | error = mark_unsafe_pages(p); | 753 | error = mark_unsafe_pages(p); |
748 | if (!error) { | 754 | if (!error) { |
749 | pblist = alloc_pagedir(nr_pages, GFP_ATOMIC, 1); | 755 | pblist = alloc_pagedir(nr_pages, GFP_ATOMIC, PG_SAFE); |
750 | if (pblist) | 756 | if (pblist) |
751 | copy_page_backup_list(pblist, p); | 757 | copy_page_backup_list(pblist, p); |
752 | free_pagedir(p, 0); | 758 | free_pagedir(p, PG_UNSAFE_KEEP); |
753 | if (!pblist) | 759 | if (!pblist) |
754 | error = -ENOMEM; | 760 | error = -ENOMEM; |
755 | } | 761 | } |
@@ -840,7 +846,7 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count) | |||
840 | return 0; | 846 | return 0; |
841 | if (!buffer) { | 847 | if (!buffer) { |
842 | /* This makes the buffer be freed by swsusp_free() */ | 848 | /* This makes the buffer be freed by swsusp_free() */ |
843 | buffer = alloc_image_page(GFP_ATOMIC, 0); | 849 | buffer = alloc_image_page(GFP_ATOMIC, PG_ANY); |
844 | if (!buffer) | 850 | if (!buffer) |
845 | return -ENOMEM; | 851 | return -ENOMEM; |
846 | } | 852 | } |