aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/snapshot.c19
-rw-r--r--kernel/power/swsusp.c45
2 files changed, 28 insertions, 36 deletions
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 42a628704398..723f5179883e 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -168,9 +168,8 @@ static unsigned count_data_pages(void)
168{ 168{
169 struct zone *zone; 169 struct zone *zone;
170 unsigned long zone_pfn; 170 unsigned long zone_pfn;
171 unsigned n; 171 unsigned int n = 0;
172 172
173 n = 0;
174 for_each_zone (zone) { 173 for_each_zone (zone) {
175 if (is_highmem(zone)) 174 if (is_highmem(zone))
176 continue; 175 continue;
@@ -250,10 +249,10 @@ static inline void fill_pb_page(struct pbe *pbpage)
250 * of memory pages allocated with alloc_pagedir() 249 * of memory pages allocated with alloc_pagedir()
251 */ 250 */
252 251
253void create_pbe_list(struct pbe *pblist, unsigned nr_pages) 252void create_pbe_list(struct pbe *pblist, unsigned int nr_pages)
254{ 253{
255 struct pbe *pbpage, *p; 254 struct pbe *pbpage, *p;
256 unsigned num = PBES_PER_PAGE; 255 unsigned int num = PBES_PER_PAGE;
257 256
258 for_each_pb_page (pbpage, pblist) { 257 for_each_pb_page (pbpage, pblist) {
259 if (num >= nr_pages) 258 if (num >= nr_pages)
@@ -293,9 +292,9 @@ static void *alloc_image_page(void)
293 * On each page we set up a list of struct_pbe elements. 292 * On each page we set up a list of struct_pbe elements.
294 */ 293 */
295 294
296struct pbe *alloc_pagedir(unsigned nr_pages) 295struct pbe *alloc_pagedir(unsigned int nr_pages)
297{ 296{
298 unsigned num; 297 unsigned int num;
299 struct pbe *pblist, *pbe; 298 struct pbe *pblist, *pbe;
300 299
301 if (!nr_pages) 300 if (!nr_pages)
@@ -329,7 +328,7 @@ void swsusp_free(void)
329 for_each_zone(zone) { 328 for_each_zone(zone) {
330 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn) 329 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn)
331 if (pfn_valid(zone_pfn + zone->zone_start_pfn)) { 330 if (pfn_valid(zone_pfn + zone->zone_start_pfn)) {
332 struct page * page; 331 struct page *page;
333 page = pfn_to_page(zone_pfn + zone->zone_start_pfn); 332 page = pfn_to_page(zone_pfn + zone->zone_start_pfn);
334 if (PageNosave(page) && PageNosaveFree(page)) { 333 if (PageNosave(page) && PageNosaveFree(page)) {
335 ClearPageNosave(page); 334 ClearPageNosave(page);
@@ -348,7 +347,7 @@ void swsusp_free(void)
348 * free pages. 347 * free pages.
349 */ 348 */
350 349
351static int enough_free_mem(unsigned nr_pages) 350static int enough_free_mem(unsigned int nr_pages)
352{ 351{
353 pr_debug("swsusp: available memory: %u pages\n", nr_free_pages()); 352 pr_debug("swsusp: available memory: %u pages\n", nr_free_pages());
354 return nr_free_pages() > (nr_pages + PAGES_FOR_IO + 353 return nr_free_pages() > (nr_pages + PAGES_FOR_IO +
@@ -356,7 +355,7 @@ static int enough_free_mem(unsigned nr_pages)
356} 355}
357 356
358 357
359static struct pbe *swsusp_alloc(unsigned nr_pages) 358static struct pbe *swsusp_alloc(unsigned int nr_pages)
360{ 359{
361 struct pbe *pblist, *p; 360 struct pbe *pblist, *p;
362 361
@@ -380,7 +379,7 @@ static struct pbe *swsusp_alloc(unsigned nr_pages)
380 379
381asmlinkage int swsusp_save(void) 380asmlinkage int swsusp_save(void)
382{ 381{
383 unsigned nr_pages; 382 unsigned int nr_pages;
384 383
385 pr_debug("swsusp: critical section: \n"); 384 pr_debug("swsusp: critical section: \n");
386 if (save_highmem()) { 385 if (save_highmem()) {
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 */
98suspend_pagedir_t *pagedir_nosave __nosavedata = NULL; 92suspend_pagedir_t *pagedir_nosave __nosavedata = NULL;
99suspend_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;
122static unsigned short swapfile_used[MAX_SWAPFILES]; 115static unsigned short swapfile_used[MAX_SWAPFILES];
123static unsigned short root_swap; 116static unsigned short root_swap;
124 117
125static int write_page(unsigned long addr, swp_entry_t * loc); 118static int write_page(unsigned long addr, swp_entry_t *loc);
126static int bio_read_page(pgoff_t page_off, void * page); 119static int bio_read_page(pgoff_t page_off, void *page);
127 120
128static u8 key_iv[MAXKEY+MAXIV]; 121static 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 */
358static int write_page(unsigned long addr, swp_entry_t * loc) 351static 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)
383static void data_free(void) 376static 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)
492static int write_pagedir(void) 485static 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
546int enough_swap(unsigned nr_pages) 539int 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
697static struct pbe * swsusp_pagedir_relocate(struct pbe *pblist) 690static 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
771static atomic_t io_done = ATOMIC_INIT(0); 764static atomic_t io_done = ATOMIC_INIT(0);
772 765
773static int end_io(struct bio * bio, unsigned int num, int err) 766static 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
781static struct block_device * resume_bdev; 774static 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
794static int submit(int rw, pgoff_t page_off, void * page) 787static 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
826static int bio_read_page(pgoff_t page_off, void * page) 819static 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
831static int bio_write_page(pgoff_t page_off, void * page) 824static 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
841static const char * sanity_check(void) 834static 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
865static int check_header(void) 858static 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
913static int data_read(struct pbe *pblist) 906static 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)
950static int read_pagedir(struct pbe *pblist) 943static 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)