I made a patch and would like feedback/testers (drivers/cdrom/aztcd.c)

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

 




Hello!

I made a patch and I would like feedback.
If you can test the patch.. please let me know.

Background:
There are busy loops that time out after 8 million repetitions.
I made these improvements:
* Sleep during the busy loops
* Time out is based on elapsed time

If this patch is accepted, AZT_TIMEOUT can be removed.

Best regards,
Daniel Marjamäki

diff -up a/drivers/cdrom/aztcd.c b/drivers/cdrom/aztcd.c

--- a/drivers/cdrom/aztcd.c	2005-11-17 11:39:53.000000000 +0100
+++ b/drivers/cdrom/aztcd.c	2005-11-19 17:14:58.000000000 +0100
@@ -179,6 +179,7 @@
 #include <linux/ioport.h>
 #include <linux/string.h>
 #include <linux/major.h>
+#include <linux/jiffies.h>

 #include <linux/init.h>

@@ -308,7 +309,7 @@ static char aztDiskChanged = 1;
 static char aztTocUpToDate = 0;

 static unsigned char aztIndatum;
-static unsigned long aztTimeOutCount;
+static unsigned long aztTimeOutCount, aztTimeOut;
 static int aztCmd = 0;

 static DEFINE_SPINLOCK(aztSpin);
@@ -361,14 +362,14 @@ static int azt_bcd2bin(unsigned char bcd
 # define OP_OK op_ok()
 static void op_ok(void)
 {
-	aztTimeOutCount = 0;
+	aztTimeOut = jiffies + 2;
 	do {
 		aztIndatum = inb(DATA_PORT);
-		aztTimeOutCount++;
-		if (aztTimeOutCount >= AZT_TIMEOUT) {
+		if (time_after(jiffies, aztTimeOut)) {
 			printk("aztcd: Error Wait OP_OK\n");
 			break;
 		}
+		schedule_timeout_interruptible(1);
 	} while (aztIndatum != AFL_OP_OK);
 }

@@ -377,14 +378,14 @@ static void op_ok(void)
 # define PA_OK pa_ok()
 static void pa_ok(void)
 {
-	aztTimeOutCount = 0;
+	aztTimeOut = jiffies + 2;
 	do {
 		aztIndatum = inb(DATA_PORT);
-		aztTimeOutCount++;
-		if (aztTimeOutCount >= AZT_TIMEOUT) {
+		if (time_after(jiffies, aztTimeOut)) {
 			printk("aztcd: Error Wait PA_OK\n");
 			break;
 		}
+		schedule_timeout_interruptible(1);
 	} while (aztIndatum != AFL_PA_OK);
 }
 #endif
@@ -393,17 +394,17 @@ static void pa_ok(void)
 # define STEN_LOW  sten_low()
 static void sten_low(void)
 {
-	aztTimeOutCount = 0;
+	aztTimeOut = jiffies + 2;
 	do {
 		aztIndatum = inb(STATUS_PORT);
-		aztTimeOutCount++;
-		if (aztTimeOutCount >= AZT_TIMEOUT) {
+		if (time_after(jiffies, aztTimeOut)) {
 			if (azt_init_end)
 				printk
 				    ("aztcd: Error Wait STEN_LOW commands:%x\n",
 				     aztCmd);
 			break;
 		}
+		schedule_timeout_interruptible(1);
 	} while (aztIndatum & AFL_STATUS);
 }

@@ -411,14 +412,14 @@ static void sten_low(void)
 # define DTEN_LOW dten_low()
 static void dten_low(void)
 {
-	aztTimeOutCount = 0;
+	aztTimeOut = jiffies + 2;
 	do {
 		aztIndatum = inb(STATUS_PORT);
-		aztTimeOutCount++;
-		if (aztTimeOutCount >= AZT_TIMEOUT) {
+		if (time_after(jiffies, aztTimeOut)) {
 			printk("aztcd: Error Wait DTEN_OK\n");
 			break;
 		}
+		schedule_timeout_interruptible(1);
 	} while (aztIndatum & AFL_DATA);
 }



-
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