]> Pileus Git - ~andy/linux/blobdiff - kernel/power/swap.c
Merge branch 'master' into upstream
[~andy/linux] / kernel / power / swap.c
index 9177f3f73a6ce8bff9e0b03249786d1a64c43acc..f1dd146bd64dd97237e5d4fb5d08cefaf3712158 100644 (file)
@@ -263,7 +263,6 @@ int swsusp_write(void)
        struct swap_map_handle handle;
        struct snapshot_handle snapshot;
        struct swsusp_info *header;
-       unsigned long start;
        int error;
 
        if ((error = swsusp_swap_check())) {
@@ -281,16 +280,17 @@ int swsusp_write(void)
        }
        error = get_swap_writer(&handle);
        if (!error) {
-               start = handle.cur_swap;
+               unsigned long start = handle.cur_swap;
                error = swap_write_page(&handle, header);
-       }
-       if (!error)
-               error = save_image(&handle, &snapshot, header->pages - 1);
-       if (!error) {
-               flush_swap_writer(&handle);
-               printk("S");
-               error = mark_swapfiles(swp_entry(root_swap, start));
-               printk("|\n");
+               if (!error)
+                       error = save_image(&handle, &snapshot,
+                                       header->pages - 1);
+               if (!error) {
+                       flush_swap_writer(&handle);
+                       printk("S");
+                       error = mark_swapfiles(swp_entry(root_swap, start));
+                       printk("|\n");
+               }
        }
        if (error)
                free_all_swap_pages(root_swap, handle.bitmap);
@@ -311,8 +311,10 @@ static atomic_t io_done = ATOMIC_INIT(0);
 
 static int end_io(struct bio *bio, unsigned int num, int err)
 {
-       if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
-               panic("I/O error reading memory image");
+       if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
+               printk(KERN_ERR "I/O error reading swsusp image.\n");
+               return -EIO;
+       }
        atomic_set(&io_done, 0);
        return 0;
 }
@@ -454,10 +456,11 @@ static int load_image(struct swap_map_handle *handle,
                        nr_pages++;
                }
        } while (ret > 0);
-       if (!error)
+       if (!error) {
                printk("\b\b\b\bdone\n");
-       if (!snapshot_image_loaded(snapshot))
-               error = -ENODATA;
+               if (!snapshot_image_loaded(snapshot))
+                       error = -ENODATA;
+       }
        return error;
 }