Tim Waugh (tim@cyberelk.demon.co.uk)
Fri, 22 Jan 1999 08:49:39 +0000 (GMT)
Okay, I'm now quite hopeful that this patch will fix the problems that
people are seeing.  I ran into "insmod parport_pc wouldn't work" just now,
and this sorted everything out.
This is called patch-2.2.0-pre9-parportpc, and is also available at
ftp://ftp.torque.net/pub/parport.
Tim.
*/
--- /big/linux-2.2.0-pre9/drivers/misc/parport_pc.c	Sun Jan  3 13:34:30 1999
+++ linux/drivers/misc/parport_pc.c	Fri Jan 22 08:47:00 1999
@@ -378,34 +378,35 @@
  */
 static int parport_ECR_present(struct parport *pb)
 {
-	unsigned char r, octr = parport_pc_read_control(pb);
-	unsigned char oecr = parport_pc_read_econtrol(pb);
-	unsigned char tmp;
+	unsigned char r;
 
+	parport_pc_write_control (pb, 0xc);
         r = parport_pc_read_control(pb);	
         if ((parport_pc_read_econtrol(pb) & 0x3) == (r & 0x3)) {
                 parport_pc_write_control(pb, r ^ 0x2 ); /* Toggle bit 1 */
 
                 r = parport_pc_read_control(pb);	
-		if ((parport_pc_read_econtrol(pb) & 0x2) == (r & 0x2)) {
-			parport_pc_write_control(pb, octr);
-			return 0; /* Sure that no ECR register exists */
-		}
+		if ((parport_pc_read_econtrol(pb) & 0x2) == (r & 0x2))
+			goto no_reg; /* Sure that no ECR register exists */
         }
         
         if ((parport_pc_read_econtrol(pb) & 0x3 ) != 0x1)
-		return 0;
+		goto no_reg;
 
         parport_pc_write_econtrol(pb, 0x34);
-	tmp = parport_pc_read_econtrol(pb);
+	if (parport_pc_read_econtrol(pb) != 0x35)
+		goto no_reg;
 
-	parport_pc_write_econtrol(pb, oecr);
-	parport_pc_write_control(pb, octr);
-	
-	if (tmp != 0x35)
-		return 0;
+	parport_pc_write_control(pb, 0xc);
 
+	/* Go to mode 000; SPP, reset FIFO */
+	parport_pc_frob_econtrol (pb, 0xe0, 0x00);
+	
         return PARPORT_MODE_PCECR;
+
+ no_reg:
+	parport_pc_write_control (pb, 0xc);
+	return 0;
 }
 
 static int parport_ECP_supported(struct parport *pb)
@@ -706,14 +707,13 @@
 
 static int probe_one_port(unsigned long int base, int irq, int dma)
 {
-	struct parport tmpport, *p;
+	unsigned int modes;
+	struct parport tmpport, *p = &tmpport;
         int probedirq = PARPORT_IRQ_NONE;
         if (check_region(base, 3)) return 0;
         tmpport.base = base;
         tmpport.ops = &parport_pc_ops;
-	if (!(parport_SPP_supported(&tmpport))) return 0;
-       	if (!(p = parport_register_port(base, irq, dma, &parport_pc_ops))) return 0;
-	p->modes = PARPORT_MODE_PCSPP | parport_PS2_supported(p);
+	tmpport.modes = 0;
         if (p->base != 0x3bc) {
                 if (!check_region(base+0x400,3)) {
                         p->modes |= parport_ECR_present(p);	
@@ -725,6 +725,13 @@
                         p->modes |= parport_ECPEPP_supported(p);
                 }
         }
+	if (!parport_SPP_supported(p))
+		/* No port. */
+		return 0;
+	modes = p->modes | PARPORT_MODE_PCSPP | parport_PS2_supported(p);
+       	if (!(p = parport_register_port(base, irq, dma, &parport_pc_ops)))
+		return 0;
+	p->modes = modes;
         p->size = (p->modes & (PARPORT_MODE_PCEPP 
                                | PARPORT_MODE_PCECPEPP))?8:3;
         printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base);
--  To unsubscribe, send mail to: linux-parport-request@torque.net --
--  with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2.0b3 on Fri 22 Jan 1999 - 03:52:41 EST