Testers required

Tim Waugh (tim@cyberelk.demon.co.uk)
Sat, 6 Mar 1999 13:02:29 +0000 (GMT)


Hi guys,

I've got a couple of patches that I'd like to see in a future 2.2 kernel.

The first (patch-2.2.2-nibble) is to correct the IEEE 1284 negotiation --
without this it seems that a nibble could get missed, and all the bytes
would slip. An example of the kind of symptom that this would cause is
the IEEE 1284 autoprobe finding an "Unspecified" device type.

diff -durN linux-2.2.2/drivers/misc/parport_ieee1284.c linux/drivers/misc/parport_ieee1284.c
--- linux-2.2.2/drivers/misc/parport_ieee1284.c Tue Feb 23 09:17:15 1999
+++ linux/drivers/misc/parport_ieee1284.c Fri Mar 5 13:24:14 1999
@@ -69,5 +69,6 @@
& ~1) & ~2);
udelay(1);
/* Data available? */
- return (parport_wait_peripheral(port, 0x20, 0))?1:2;
+ parport_wait_peripheral (port, PARPORT_STATUS_ACK, PARPORT_STATUS_ACK);
+ return (parport_read_status(port) & PARPORT_STATUS_ERROR)?1:2;
}

The second (patch-2.2.2-lpread-2) is to correct a bug in lp_read that
would cause data loss when the peripheral has more data ready than the
user is prepared to read.

diff -durN linux-2.2.2/drivers/char/lp.c linux/drivers/char/lp.c
--- linux-2.2.2/drivers/char/lp.c Fri Nov 27 18:23:11 1998
+++ linux/drivers/char/lp.c Fri Mar 5 13:27:52 1999
@@ -589,15 +589,6 @@

#ifdef CONFIG_PRINTER_READBACK

-static int lp_read_nibble(int minor)
-{
- unsigned char i;
- i = r_str(minor)>>3;
- i &= ~8;
- if ((i & 0x10) == 0) i |= 8;
- return (i & 0x0f);
-}
-
static void lp_read_terminate(struct parport *port) {
parport_write_control(port, (parport_read_control(port) & ~2) | 8);
/* SelectIN high, AutoFeed low */
@@ -617,10 +608,9 @@
{
int i;
unsigned int minor=MINOR(file->f_dentry->d_inode->i_rdev);
- char *temp = buf;
ssize_t count = 0;
- unsigned char z = 0;
- unsigned char Byte = 0;
+ unsigned char byte = 0;
+ int ret;
struct parport *port = lp_table[minor].dev->port;

lp_parport_claim (minor);
@@ -645,43 +635,70 @@
break;
}

- for (i=0; ; i++) {
- parport_frob_control(port, 2, 2); /* AutoFeed high */
- if (parport_wait_peripheral(port, 0x40, 0)) {
+ length *= 2; /* in nibbles */
+ for (i = 0; i < length; i++) {
+ unsigned char nibble;
+
+ /* Does the error line indicate end of data? */
+ if (((i & 1) == 0) &&
+ (parport_read_status (port) & PARPORT_STATUS_ERROR)) {
+ /* Go to reverse idle phase. */
#ifdef LP_READ_DEBUG
- /* Some peripherals just time out when they've sent
- all their data. */
- printk("%s: read1 timeout.\n", port->name);
+ printk (KERN_DEBUG "No more nibble data (%d)\n",
+ count);
#endif
- parport_frob_control(port, 2, 0); /* AutoFeed low */
+ parport_frob_control (port,
+ PARPORT_CONTROL_AUTOFD,
+ PARPORT_CONTROL_AUTOFD);
break;
}
- z = lp_read_nibble(minor);
- parport_frob_control(port, 2, 0); /* AutoFeed low */
- if (parport_wait_peripheral(port, 0x40, 0x40)) {
- printk("%s: read2 timeout.\n", port->name);
+
+ /* nAutoFd low. */
+ parport_frob_control (port,
+ PARPORT_CONTROL_AUTOFD,
+ PARPORT_CONTROL_AUTOFD);
+
+ /* nAck goes low. */
+ if (parport_wait_peripheral (port, PARPORT_STATUS_ACK, 0)) {
+ /* Timeout -- no more data? */
+#ifdef LP_READ_DEBUG
+ printk (KERN_DEBUG "Nibble timeout at event 9\n");
+#endif
break;
}
- if ((i & 1) != 0) {
- Byte |= (z<<4);
- if (temp) {
- if (__put_user (Byte, temp))
- {
- count = -EFAULT;
- temp = NULL;
- } else {
- temp++;

- if (++count == length)
- temp = NULL;
- }
- }
- /* Does the error line indicate end of data? */
- if ((parport_read_status(port) & LP_PERRORP) ==
- LP_PERRORP)
+ /* Read a nibble. */
+ nibble = parport_read_status (port) >> 3;
+ nibble &= ~8;
+ if ((nibble & 0x10) == 0)
+ nibble |= 8;
+ nibble &= 0xf;
+
+ /* Set nAutoFd high. */
+ parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0);
+
+ /* nAck goes high. */
+ if (parport_wait_peripheral (port,
+ PARPORT_STATUS_ACK,
+ PARPORT_STATUS_ACK)) {
+ /* Timeout -- no more data? */
+#ifdef LP_READ_DEBUG
+ printk (KERN_DEBUG "Nibble timeout at event 11\n");
+#endif
+ break;
+ }
+
+ if (i & 1) {
+ /* Second nibble */
+ byte |= nibble << 4;
+ if ((ret = __put_user (byte, buf)) != 0) {
+ count = ret;
break;
- } else
- Byte=z;
+ }
+ buf++;
+ count++;
+ } else
+ byte = nibble;
}

lp_read_terminate(port);

Both of these patches are at <URL:ftp://ftp.torque.net/pub/parport/>.

Please test them out as much as you can.

Thanks,
Tim.
*/

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