mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* swsusp: kill one-line helpers, handle read errors
@ 2004-12-25 17:36 Pavel Machek
  0 siblings, 0 replies; only message in thread
From: Pavel Machek @ 2004-12-25 17:36 UTC (permalink / raw)
  To: Andrew Morton, kernel list

Hi!

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. Please apply,
                                                                Pavel

Signed-off-by: Pavel Machek <pavel@suse.cz>

--- clean-cvs/kernel/power/swsusp.c	2004-12-14 20:43:42.000000000 +0100
+++ linux-cvs/kernel/power/swsusp.c	2004-12-14 20:48:31.000000000 +0100
@@ -1003,24 +984,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;
 
 /**
@@ -1055,9 +1026,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;

-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-12-25 17:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-25 17:36 swsusp: kill one-line helpers, handle read errors Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®