swsusp: clean up reading
From: Pavel Machek
Date: Fri Sep 10 2004 - 04:33:46 EST
Hi!
This removes one-line functions so that code is readable again. Test
is added so that we do not ignore I/O errors. It also turns
io_schedule() into yield() as suggested by Andrea. Please apply,
Pavel
--- clean-mm/kernel/power/swsusp.c 2004-09-07 21:12:33.000000000 +0200
+++ linux-mm/kernel/power/swsusp.c 2004-09-09 08:56:20.000000000 +0200
@@ -994,24 +978,14 @@
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;
/**
@@ -1046,9 +1020,12 @@
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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/