From: Pavel Machek swsusp contains few one-line helpers that only make reading/understanding code more difficult. Also warn the user when something goes wrong, instead of waking machine with corrupt data. Signed-off-by: Pavel Machek Signed-off-by: Andrew Morton --- 25-akpm/kernel/power/swsusp.c | 23 ++++++++--------------- 1 files changed, 8 insertions(+), 15 deletions(-) diff -puN kernel/power/swsusp.c~swsusp-kill-one-line-helpers-handle-read-errors kernel/power/swsusp.c --- 25/kernel/power/swsusp.c~swsusp-kill-one-line-helpers-handle-read-errors 2004-12-27 01:01:30.751292672 -0800 +++ 25-akpm/kernel/power/swsusp.c 2004-12-27 01:01:30.754292216 -0800 @@ -1002,24 +1002,14 @@ static int __init swsusp_pagedir_relocat static atomic_t io_done = ATOMIC_INIT(0); -static void start_io(void) -{ - atomic_set(&io_done,1); -} - static int end_io(struct bio * bio, unsigned int num, int err) { - atomic_set(&io_done,0); + if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) + panic("I/O error reading memory image"); + atomic_set(&io_done, 0); return 0; } -static void wait_io(void) -{ - while(atomic_read(&io_done)) - io_schedule(); -} - - static struct block_device * resume_bdev; /** @@ -1054,9 +1044,12 @@ static int submit(int rw, pgoff_t page_o if (rw == WRITE) bio_set_pages_dirty(bio); - start_io(); + + atomic_set(&io_done, 1); submit_bio(rw | (1 << BIO_RW_SYNC), bio); - wait_io(); + while (atomic_read(&io_done)) + yield(); + Done: bio_put(bio); return error; _