[Linux-parport] [patch 4/5] paride/pg: replace pg_sleep() with msleep()

domen at coderock.org domen at coderock.org
Mon Jun 20 17:51:07 EDT 2005


From: Nishanth Aravamudan <nacc at us.ibm.com>



Just had a quick revelation that pg_sleep()'s parameter being labelled
as ``cs'' indicated centiseconds, which is the schedular quantum when
HZ=100. But the current driver does not account for other values of HZ.

Use msleep() instead of pg_sleep() to guarantee the task
delays as expected. Remove the now unused pg_sleep() definition.
pg_sleep()'s units were centiseconds, so the corresponding parameters to
msleep() were multiplied by 10. Patch is compile-tested.

Signed-off-by: Nishanth Aravamudan <nacc at us.ibm.com>
Signed-off-by: Domen Puncer <domen at coderock.org>
---
 pg.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

Index: quilt/drivers/block/paride/pg.c
===================================================================
--- quilt.orig/drivers/block/paride/pg.c
+++ quilt/drivers/block/paride/pg.c
@@ -274,12 +274,6 @@ static inline u8 DRIVE(struct pg *dev)
 	return 0xa0+0x10*dev->drive;
 }
 
-static void pg_sleep(int cs)
-{
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(cs);
-}
-
 static int pg_wait(struct pg *dev, int go, int stop, unsigned long tmo, char *msg)
 {
 	int j, r, e, s, p, to;
@@ -292,7 +286,7 @@ static int pg_wait(struct pg *dev, int g
 		if (j++ < PG_SPIN)
 			udelay(PG_SPIN_DEL);
 		else
-			pg_sleep(1);
+			msleep(10);
 	}
 
 	to = time_after_eq(jiffies, tmo);
@@ -390,11 +384,11 @@ static int pg_reset(struct pg *dev)
 	write_reg(dev, 6, DRIVE(dev));
 	write_reg(dev, 7, 8);
 
-	pg_sleep(20 * HZ / 1000);
+	msleep(20);
 
 	k = 0;
 	while ((k++ < PG_RESET_TMO) && (status_reg(dev) & STAT_BUSY))
-		pg_sleep(1);
+		msleep(10);
 
 	for (i = 0; i < 5; i++)
 		got[i] = read_reg(dev, i + 1);

--



More information about the Linux-parport mailing list