patch-2.3.99-pre4 linux/drivers/parport/parport_pc.c

Next file: linux/drivers/parport/parport_sunbpp.c
Previous file: linux/drivers/parport/ChangeLog
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre3/linux/drivers/parport/parport_pc.c linux/drivers/parport/parport_pc.c
@@ -178,9 +178,6 @@
 	int cnfga;
 	const struct parport_pc_private *priv = p->physport->private_data;
 
-	/* Prevent further data transfer. */
-	frob_econtrol (p, 0xe0, ECR_TST << 5);
-
 	/* Adjust for the contents of the FIFO. */
 	for (residue = priv->fifo_depth; ; residue--) {
 		if (inb (ECONTROL (p)) & 0x2)
@@ -862,7 +859,8 @@
 						       length, flags);
 
 	/* Switch to reverse mode if necessary. */
-	if (port->ieee1284.phase != IEEE1284_PH_REV_IDLE) {
+	if ((port->ieee1284.phase != IEEE1284_PH_REV_IDLE) &&
+	    (port->ieee1284.phase != IEEE1284_PH_REV_DATA)) {
 		/* Event 38: Set nAutoFd low */
 		parport_frob_control (port,
 				      PARPORT_CONTROL_AUTOFD,
@@ -879,7 +877,7 @@
 		parport_wait_peripheral (port, PARPORT_STATUS_PAPEROUT, 0);
 	}
 
-	/* Set up ECP parallel port mode.*/
+	/* Set up ECP FIFO mode.*/
 	parport_pc_data_reverse (port); /* Must be in PS2 mode */
 	parport_pc_frob_control (port,
 				 PARPORT_CONTROL_STROBE |
@@ -951,14 +949,23 @@
 		left--;
 	}
 
+	port->ieee1284.phase = IEEE1284_PH_REV_IDLE;
+
+	/* Go to forward idle mode to shut the peripheral up. */
+	parport_frob_control (port, PARPORT_CONTROL_INIT, 0);
+	parport_wait_peripheral (port,
+				 PARPORT_STATUS_PAPEROUT,
+				 PARPORT_STATUS_PAPEROUT);
+	port->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
+
 	/* Finish up. */
-	if (change_mode (port, ECR_PS2) == -EBUSY) {
+	{
 		int lost = get_fifo_residue (port);
-		printk (KERN_DEBUG "%s: DATA LOSS (%d bytes)!\n", port->name,
-			lost);
+		if (lost)
+			/* Shouldn't happen with compliant peripherals. */
+			printk (KERN_DEBUG "%s: DATA LOSS (%d bytes)!\n",
+				port->name, lost);
 	}
-
-	port->ieee1284.phase = IEEE1284_PH_REV_IDLE;
 
 	return length - left;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)