[KJ] [PATCH] block/swim_iop: replace schedule_timeout() with

DORMANTno replies

From: Nishanth Aravamudan <hidden>
Date: 2005-03-02 20:09:34

Hi,

Re-send of a patch from January 24, 2005, adding Jens this time.

Thanks,
Nish

Description: Change the delay logic of swimiop_eject() to use
msleep_interruptible() and time_before(). Rather than depend on the
number of iterations of the loop for timing accuracy, I rely on the
current value of jiffies relative to a static timeout (end_jiffies).

Signed-off-by: Nishanth Aravamudan <redacted>
--- 2.6.11-kj-v/drivers/block/swim_iop.c	2005-03-02 11:21:41.000000000 -0800
+++ 2.6.11-kj/drivers/block/swim_iop.c	2005-03-02 12:03:27.000000000 -0800
@@ -318,7 +318,8 @@ static void swimiop_status_update(int dr
 
 static int swimiop_eject(struct floppy_state *fs)
 {
-	int err, n;
+	int err;
+	unsigned long end_jiffies;
 	struct swim_iop_req req;
 	struct swimcmd_eject *cmd = (struct swimcmd_eject *) &req.command[0];
 
@@ -333,14 +334,13 @@ static int swimiop_eject(struct floppy_s
 		release_drive(fs);
 		return err;
 	}
-	for (n = 2*HZ; n > 0; --n) {
-		if (req.complete) break;
-		if (signal_pending(current)) {
+	end_jiffies = jiffies + 2 * HZ;
+	while (!req.complete && time_before(jiffies, end_jiffies)) {
+		msleep_interruptible(10);
+		if (signals_pending(current)) {
 			err = -EINTR;
 			break;
 		}
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(1);
 	}
 	release_drive(fs);
 	return cmd->error;

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help