patch-2.3.20 linux/include/linux/parport_pc.h

Next file: linux/include/linux/pci.h
Previous file: linux/include/linux/parport.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.19/linux/include/linux/parport_pc.h linux/include/linux/parport_pc.h
@@ -41,33 +41,50 @@
 
 extern __inline__ void parport_pc_write_data(struct parport *p, unsigned char d)
 {
+#ifdef DEBUG_PARPORT
+	printk (KERN_DEBUG "parport_pc_write_data(%p,0x%02x)\n", p, d);
+#endif
 	outb(d, DATA(p));
 }
 
 extern __inline__ unsigned char parport_pc_read_data(struct parport *p)
 {
-	return inb(DATA(p));
+	unsigned char val = inb (DATA (p));
+#ifdef DEBUG_PARPORT
+	printk (KERN_DEBUG "parport_pc_read_data(%p) = 0x%02x\n",
+		p, val);
+#endif
+	return val;
 }
 
-extern __inline__ unsigned char __frob_control (struct parport *p,
-						unsigned char mask,
-						unsigned char val)
+/* __parport_pc_frob_control differs from parport_pc_frob_control in that
+ * it doesn't do any extra masking. */
+static __inline__ unsigned char __parport_pc_frob_control (struct parport *p,
+							   unsigned char mask,
+							   unsigned char val)
 {
-	const unsigned char wm = (PARPORT_CONTROL_STROBE |
-				  PARPORT_CONTROL_AUTOFD |
-				  PARPORT_CONTROL_INIT |
-				  PARPORT_CONTROL_SELECT);
 	struct parport_pc_private *priv = p->physport->private_data;
 	unsigned char ctr = priv->ctr;
+#ifdef DEBUG_PARPORT
+	printk (KERN_DEBUG
+		"__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
+		mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
+#endif
 	ctr = (ctr & ~mask) ^ val;
 	ctr &= priv->ctr_writable; /* only write writable bits. */
 	outb (ctr, CONTROL (p));
-	return priv->ctr = ctr & wm; /* update soft copy */
+	priv->ctr = ctr;	/* Update soft copy */
+	return ctr;
 }
 
 extern __inline__ void parport_pc_data_reverse (struct parport *p)
 {
-	__frob_control (p, 0x20, 0x20);
+	__parport_pc_frob_control (p, 0x20, 0x20);
+}
+
+extern __inline__ void parport_pc_data_forward (struct parport *p)
+{
+	__parport_pc_frob_control (p, 0x20, 0x00);
 }
 
 extern __inline__ void parport_pc_write_control (struct parport *p,
@@ -80,18 +97,22 @@
 
 	/* Take this out when drivers have adapted to newer interface. */
 	if (d & 0x20) {
-			printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
-					p->name, p->cad->name);
-			parport_pc_data_reverse (p);
+		printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
+			p->name, p->cad->name);
+		parport_pc_data_reverse (p);
 	}
 
-	__frob_control (p, wm, d & wm);
+	__parport_pc_frob_control (p, wm, d & wm);
 }
 
 extern __inline__ unsigned char parport_pc_read_control(struct parport *p)
 {
+	const unsigned char rm = (PARPORT_CONTROL_STROBE |
+				  PARPORT_CONTROL_AUTOFD |
+				  PARPORT_CONTROL_INIT |
+				  PARPORT_CONTROL_SELECT);
 	const struct parport_pc_private *priv = p->physport->private_data;
-	return priv->ctr; /* Use soft copy */
+	return priv->ctr & rm; /* Use soft copy */
 }
 
 extern __inline__ unsigned char parport_pc_frob_control (struct parport *p,
@@ -105,16 +126,20 @@
 
 	/* Take this out when drivers have adapted to newer interface. */
 	if (mask & 0x20) {
-			printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
-					p->name, p->cad->name);
+		printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
+			p->name, p->cad->name,
+			(val & 0x20) ? "reverse" : "forward");
+		if (val & 0x20)
 			parport_pc_data_reverse (p);
+		else
+			parport_pc_data_forward (p);
 	}
 
 	/* Restrict mask and val to control lines. */
 	mask &= wm;
 	val &= wm;
 
-	return __frob_control (p, mask, val);
+	return __parport_pc_frob_control (p, mask, val);
 }
 
 extern __inline__ unsigned char parport_pc_read_status(struct parport *p)
@@ -122,19 +147,15 @@
 	return inb(STATUS(p));
 }
 
-extern __inline__ void parport_pc_data_forward (struct parport *p)
-{
-	__frob_control (p, 0x20, 0x00);
-}
 
 extern __inline__ void parport_pc_disable_irq(struct parport *p)
 {
-	__frob_control (p, 0x10, 0x00);
+	__parport_pc_frob_control (p, 0x10, 0x00);
 }
 
 extern __inline__ void parport_pc_enable_irq(struct parport *p)
 {
-	__frob_control (p, 0x10, 0x10);
+	__parport_pc_frob_control (p, 0x10, 0x10);
 }
 
 extern void parport_pc_release_resources(struct parport *p);

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