diff options
Diffstat (limited to 'kernel/power/swsusp.c')
-rw-r--r-- | kernel/power/swsusp.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index 12db1d2ad61f..e1ab28b9b217 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c | |||
@@ -85,18 +85,11 @@ unsigned int nr_copy_pages __nosavedata = 0; | |||
85 | /* Suspend pagedir is allocated before final copy, therefore it | 85 | /* Suspend pagedir is allocated before final copy, therefore it |
86 | must be freed after resume | 86 | must be freed after resume |
87 | 87 | ||
88 | Warning: this is evil. There are actually two pagedirs at time of | ||
89 | resume. One is "pagedir_save", which is empty frame allocated at | ||
90 | time of suspend, that must be freed. Second is "pagedir_nosave", | ||
91 | allocated at time of resume, that travels through memory not to | ||
92 | collide with anything. | ||
93 | |||
94 | Warning: this is even more evil than it seems. Pagedirs this file | 88 | Warning: this is even more evil than it seems. Pagedirs this file |
95 | talks about are completely different from page directories used by | 89 | talks about are completely different from page directories used by |
96 | MMU hardware. | 90 | MMU hardware. |
97 | */ | 91 | */ |
98 | suspend_pagedir_t *pagedir_nosave __nosavedata = NULL; | 92 | suspend_pagedir_t *pagedir_nosave __nosavedata = NULL; |
99 | suspend_pagedir_t *pagedir_save; | ||
100 | 93 | ||
101 | #define SWSUSP_SIG "S1SUSPEND" | 94 | #define SWSUSP_SIG "S1SUSPEND" |
102 | 95 | ||
@@ -122,8 +115,8 @@ static struct swsusp_info swsusp_info; | |||
122 | static unsigned short swapfile_used[MAX_SWAPFILES]; | 115 | static unsigned short swapfile_used[MAX_SWAPFILES]; |
123 | static unsigned short root_swap; | 116 | static unsigned short root_swap; |
124 | 117 | ||
125 | static int write_page(unsigned long addr, swp_entry_t * loc); | 118 | static int write_page(unsigned long addr, swp_entry_t *loc); |
126 | static int bio_read_page(pgoff_t page_off, void * page); | 119 | static int bio_read_page(pgoff_t page_off, void *page); |
127 | 120 | ||
128 | static u8 key_iv[MAXKEY+MAXIV]; | 121 | static u8 key_iv[MAXKEY+MAXIV]; |
129 | 122 | ||
@@ -355,7 +348,7 @@ static void lock_swapdevices(void) | |||
355 | * This is a partial improvement, since we will at least return other | 348 | * This is a partial improvement, since we will at least return other |
356 | * errors, though we need to eventually fix the damn code. | 349 | * errors, though we need to eventually fix the damn code. |
357 | */ | 350 | */ |
358 | static int write_page(unsigned long addr, swp_entry_t * loc) | 351 | static int write_page(unsigned long addr, swp_entry_t *loc) |
359 | { | 352 | { |
360 | swp_entry_t entry; | 353 | swp_entry_t entry; |
361 | int error = 0; | 354 | int error = 0; |
@@ -383,9 +376,9 @@ static int write_page(unsigned long addr, swp_entry_t * loc) | |||
383 | static void data_free(void) | 376 | static void data_free(void) |
384 | { | 377 | { |
385 | swp_entry_t entry; | 378 | swp_entry_t entry; |
386 | struct pbe * p; | 379 | struct pbe *p; |
387 | 380 | ||
388 | for_each_pbe(p, pagedir_nosave) { | 381 | for_each_pbe (p, pagedir_nosave) { |
389 | entry = p->swap_address; | 382 | entry = p->swap_address; |
390 | if (entry.val) | 383 | if (entry.val) |
391 | swap_free(entry); | 384 | swap_free(entry); |
@@ -492,8 +485,8 @@ static void free_pagedir_entries(void) | |||
492 | static int write_pagedir(void) | 485 | static int write_pagedir(void) |
493 | { | 486 | { |
494 | int error = 0; | 487 | int error = 0; |
495 | unsigned n = 0; | 488 | unsigned int n = 0; |
496 | struct pbe * pbe; | 489 | struct pbe *pbe; |
497 | 490 | ||
498 | printk( "Writing pagedir..."); | 491 | printk( "Writing pagedir..."); |
499 | for_each_pb_page (pbe, pagedir_nosave) { | 492 | for_each_pb_page (pbe, pagedir_nosave) { |
@@ -543,7 +536,7 @@ static int write_suspend_image(void) | |||
543 | * We should only consider resume_device. | 536 | * We should only consider resume_device. |
544 | */ | 537 | */ |
545 | 538 | ||
546 | int enough_swap(unsigned nr_pages) | 539 | int enough_swap(unsigned int nr_pages) |
547 | { | 540 | { |
548 | struct sysinfo i; | 541 | struct sysinfo i; |
549 | 542 | ||
@@ -694,7 +687,7 @@ static int check_pagedir(struct pbe *pblist) | |||
694 | * restore from the loaded pages later. We relocate them here. | 687 | * restore from the loaded pages later. We relocate them here. |
695 | */ | 688 | */ |
696 | 689 | ||
697 | static struct pbe * swsusp_pagedir_relocate(struct pbe *pblist) | 690 | static struct pbe *swsusp_pagedir_relocate(struct pbe *pblist) |
698 | { | 691 | { |
699 | struct zone *zone; | 692 | struct zone *zone; |
700 | unsigned long zone_pfn; | 693 | unsigned long zone_pfn; |
@@ -770,7 +763,7 @@ static struct pbe * swsusp_pagedir_relocate(struct pbe *pblist) | |||
770 | 763 | ||
771 | static atomic_t io_done = ATOMIC_INIT(0); | 764 | static atomic_t io_done = ATOMIC_INIT(0); |
772 | 765 | ||
773 | static int end_io(struct bio * bio, unsigned int num, int err) | 766 | static int end_io(struct bio *bio, unsigned int num, int err) |
774 | { | 767 | { |
775 | if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) | 768 | if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) |
776 | panic("I/O error reading memory image"); | 769 | panic("I/O error reading memory image"); |
@@ -778,7 +771,7 @@ static int end_io(struct bio * bio, unsigned int num, int err) | |||
778 | return 0; | 771 | return 0; |
779 | } | 772 | } |
780 | 773 | ||
781 | static struct block_device * resume_bdev; | 774 | static struct block_device *resume_bdev; |
782 | 775 | ||
783 | /** | 776 | /** |
784 | * submit - submit BIO request. | 777 | * submit - submit BIO request. |
@@ -791,10 +784,10 @@ static struct block_device * resume_bdev; | |||
791 | * Then submit it and wait. | 784 | * Then submit it and wait. |
792 | */ | 785 | */ |
793 | 786 | ||
794 | static int submit(int rw, pgoff_t page_off, void * page) | 787 | static int submit(int rw, pgoff_t page_off, void *page) |
795 | { | 788 | { |
796 | int error = 0; | 789 | int error = 0; |
797 | struct bio * bio; | 790 | struct bio *bio; |
798 | 791 | ||
799 | bio = bio_alloc(GFP_ATOMIC, 1); | 792 | bio = bio_alloc(GFP_ATOMIC, 1); |
800 | if (!bio) | 793 | if (!bio) |
@@ -823,12 +816,12 @@ static int submit(int rw, pgoff_t page_off, void * page) | |||
823 | return error; | 816 | return error; |
824 | } | 817 | } |
825 | 818 | ||
826 | static int bio_read_page(pgoff_t page_off, void * page) | 819 | static int bio_read_page(pgoff_t page_off, void *page) |
827 | { | 820 | { |
828 | return submit(READ, page_off, page); | 821 | return submit(READ, page_off, page); |
829 | } | 822 | } |
830 | 823 | ||
831 | static int bio_write_page(pgoff_t page_off, void * page) | 824 | static int bio_write_page(pgoff_t page_off, void *page) |
832 | { | 825 | { |
833 | return submit(WRITE, page_off, page); | 826 | return submit(WRITE, page_off, page); |
834 | } | 827 | } |
@@ -838,7 +831,7 @@ static int bio_write_page(pgoff_t page_off, void * page) | |||
838 | * I really don't think that it's foolproof but more than nothing.. | 831 | * I really don't think that it's foolproof but more than nothing.. |
839 | */ | 832 | */ |
840 | 833 | ||
841 | static const char * sanity_check(void) | 834 | static const char *sanity_check(void) |
842 | { | 835 | { |
843 | dump_info(); | 836 | dump_info(); |
844 | if (swsusp_info.version_code != LINUX_VERSION_CODE) | 837 | if (swsusp_info.version_code != LINUX_VERSION_CODE) |
@@ -864,7 +857,7 @@ static const char * sanity_check(void) | |||
864 | 857 | ||
865 | static int check_header(void) | 858 | static int check_header(void) |
866 | { | 859 | { |
867 | const char * reason = NULL; | 860 | const char *reason = NULL; |
868 | int error; | 861 | int error; |
869 | 862 | ||
870 | if ((error = bio_read_page(swp_offset(swsusp_header.swsusp_info), &swsusp_info))) | 863 | if ((error = bio_read_page(swp_offset(swsusp_header.swsusp_info), &swsusp_info))) |
@@ -912,7 +905,7 @@ static int check_sig(void) | |||
912 | 905 | ||
913 | static int data_read(struct pbe *pblist) | 906 | static int data_read(struct pbe *pblist) |
914 | { | 907 | { |
915 | struct pbe * p; | 908 | struct pbe *p; |
916 | int error = 0; | 909 | int error = 0; |
917 | int i = 0; | 910 | int i = 0; |
918 | int mod = swsusp_info.image_pages / 100; | 911 | int mod = swsusp_info.image_pages / 100; |
@@ -950,7 +943,7 @@ static int data_read(struct pbe *pblist) | |||
950 | static int read_pagedir(struct pbe *pblist) | 943 | static int read_pagedir(struct pbe *pblist) |
951 | { | 944 | { |
952 | struct pbe *pbpage, *p; | 945 | struct pbe *pbpage, *p; |
953 | unsigned i = 0; | 946 | unsigned int i = 0; |
954 | int error; | 947 | int error; |
955 | 948 | ||
956 | if (!pblist) | 949 | if (!pblist) |