[PATCH] swim3: replace schedule_timeout() with msleep_interruptible() From: Nishanth Aravamudan Change the delay logic to use time_before() and msleep_interruptible(). 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 Signed-off-by: Domen Puncer Signed-off-by: Alexey Dobriyan Index: linux-kj/drivers/block/swim3.c =================================================================== --- linux-kj.orig/drivers/block/swim3.c 2005-10-28 16:25:14.000000000 +0400 +++ linux-kj/drivers/block/swim3.c 2005-10-28 16:26:19.000000000 +0400 @@ -822,13 +822,15 @@ static void release_drive(struct floppy_ static int fd_eject(struct floppy_state *fs) { - int err, n; + int err; + unsigned long end_jiffies; err = grab_drive(fs, ejecting, 1); if (err) return err; swim3_action(fs, EJECT); - for (n = 20; n > 0; --n) { + end_jiffies = jiffies + 20; + while (time_before(jiffies, end_jiffies)) { if (signal_pending(current)) { err = -EINTR; break; @@ -881,7 +883,8 @@ static int floppy_open(struct inode *ino { struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; struct swim3 __iomem *sw = fs->swim3; - int n, err = 0; + int err = 0; + unsigned long end_jiffies, check_jiffies; if (fs->ref_count == 0) { #ifdef CONFIG_PMAC_MEDIABAY @@ -897,8 +900,11 @@ static int floppy_open(struct inode *ino swim3_action(fs, MOTOR_ON); fs->write_prot = -1; fs->cur_cyl = -1; - for (n = 0; n < 2 * HZ; ++n) { - if (n >= HZ/30 && swim3_readbit(fs, SEEK_COMPLETE)) + end_jiffies = jiffies + 2 * HZ; + check_jiffies = jiffies + HZ/30; + while (time_before(jiffies, end_jiffies)) { + if (time_after(jiffies, check_jiffies) && + swim3_readbit(fs, SEEK_COMPLETE)) break; if (signal_pending(current)) { err = -EINTR; @@ -969,7 +975,8 @@ static int floppy_revalidate(struct gend { struct floppy_state *fs = disk->private_data; struct swim3 __iomem *sw; - int ret, n; + int ret; + unsigned long end_jiffies; #ifdef CONFIG_PMAC_MEDIABAY if (fs->media_bay && check_media_bay(fs->media_bay, MB_FD)) @@ -984,7 +991,8 @@ static int floppy_revalidate(struct gend fs->write_prot = -1; fs->cur_cyl = -1; mdelay(1); - for (n = HZ; n > 0; --n) { + end_jiffies = jiffies + HZ; + while (time_before(jiffies, end_jiffies)) { if (swim3_readbit(fs, SEEK_COMPLETE)) break; if (signal_pending(current))