[patch 10/12] block/swim_iop: replace schedule_timeout() with msleep_interruptible()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nishanth Aravamudan <[email protected]>


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 <[email protected]>
Signed-off-by: Domen Puncer <[email protected]>
---
 swim_iop.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

Index: quilt/drivers/block/swim_iop.c
===================================================================
--- quilt.orig/drivers/block/swim_iop.c
+++ quilt/drivers/block/swim_iop.c
@@ -317,7 +317,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];
 
@@ -332,14 +333,13 @@ static int swimiop_eject(struct floppy_s
 		release_drive(fs);
 		return err;
 	}
-	for (n = 2*HZ; n > 0; --n) {
-		if (req.complete) break;
+	end_jiffies = jiffies + 2 * HZ;
+	while (!req.complete && time_before(jiffies, end_jiffies)) {
+		msleep_interruptible(10);
 		if (signal_pending(current)) {
 			err = -EINTR;
 			break;
 		}
-		current->state = TASK_INTERRUPTIBLE;
-		schedule_timeout(1);
 	}
 	release_drive(fs);
 	return cmd->error;

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux