[patch] 2.3.41pre4: lp ioctl for controlling parport timeout

Tim Waugh twaugh en redhat.com
Vie Ene 28 20:27:18 CST 2000


Here's a patch that adds an ioctl to lp for controlling the timeout on
parport_write.  Tuning this might give a performance boost to people using
FIFO/DMA transfers.

Tim.
*/

Index: linux/drivers/char/lp.c
diff -u linux/drivers/char/lp.c:1.1.1.4 linux/drivers/char/lp.c:1.5
--- linux/drivers/char/lp.c:1.1.1.4	Thu Jan  6 11:44:23 2000
+++ linux/drivers/char/lp.c	Fri Jan 28 17:24:46 2000
@@ -321,6 +321,7 @@
 	ssize_t retv = 0;
 	ssize_t written;
 	size_t copy_size = count;
+	long old_to;
 
 #ifdef LP_STATS
 	if (jiffies-lp_table[minor].lastcall > LP_TIME(minor))
@@ -346,6 +347,9 @@
 	/* Go to compatibility mode. */
 	parport_negotiate (port, IEEE1284_MODE_COMPAT);
 
+	old_to = parport_set_timeout (lp_table[minor].dev,
+				      lp_table[minor].timeout);
+
 	do {
 		/* Write the data. */
 		written = parport_write (port, kbuf, copy_size);
@@ -390,6 +394,9 @@
 		}	
 	} while (count > 0);
 
+	/* Not really necessary, but polite. */
+	parport_set_timeout (lp_table[minor].dev, old_to);
+
  	lp_parport_release (minor);
 
 	up (&lp_table[minor].port_mutex);
@@ -588,6 +595,11 @@
 			if (copy_to_user((int *) arg, &status, sizeof(int)))
 				return -EFAULT;
 			break;
+
+		case LPSETTIMEOUT:
+			lp_table[minor].timeout = arg;
+			break;
+
 		default:
 			retval = -EINVAL;
 	}
@@ -854,6 +866,7 @@
 		init_waitqueue_head (&lp_table[i].waitq);
 		init_waitqueue_head (&lp_table[i].dataq);
 		init_MUTEX (&lp_table[i].port_mutex);
+		lp_table[i].timeout = 10 * HZ;
 	}
 
 	if (register_chrdev (LP_MAJOR, "lp", &lp_fops)) {
Index: linux/include/linux/lp.h
diff -u linux/include/linux/lp.h:1.1.1.2 linux/include/linux/lp.h:1.2
--- linux/include/linux/lp.h:1.1.1.2	Thu Oct 14 21:43:13 1999
+++ linux/include/linux/lp.h	Fri Jan 28 17:25:36 2000
@@ -89,6 +89,7 @@
 #define LPGETSTATS  0x060d  /* get statistics (struct lp_stats) */
 #endif
 #define LPGETFLAGS  0x060e  /* get status flags */
+#define LPSETTIMEOUT 0x060f /* set parport timeout */
 
 /* timeout for printk'ing a timeout, in jiffies (100ths of a second).
    This is also used for re-checking error conditions if LP_ABORT is
@@ -145,6 +146,7 @@
 	unsigned int last_error;
 	struct semaphore port_mutex;
 	wait_queue_head_t dataq;
+	long timeout;
 };
 
 /*


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda