patch-2.1.36 linux/drivers/pnp/parport_share.c

Next file: linux/drivers/sbus/char/Config.in
Previous file: linux/drivers/pnp/parport_procfs.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.35/linux/drivers/pnp/parport_share.c linux/drivers/pnp/parport_share.c
@@ -1,4 +1,4 @@
-/* $Id: parport_share.c,v 1.1.2.4 1997/04/01 18:19:11 phil Exp $
+/* $Id: parport_share.c,v 1.3.2.5 1997/04/16 21:20:44 phil Exp $
  * Parallel-port resource manager code.
  * 
  * Authors: David Campbell <campbell@tirian.che.curtin.edu.au>
@@ -21,6 +21,8 @@
 #include <linux/kernel.h>
 #include <linux/malloc.h>
 
+#undef PARPORT_PARANOID
+
 #include "parport_ll_io.h"
 
 static struct parport *portlist = NULL, *portlist_tail = NULL;
@@ -36,7 +38,7 @@
 	return portlist;
 }
 
-static void parport_null_intr_func(int irq, void *dev_id, struct pt_regs *regs)
+void parport_null_intr_func(int irq, void *dev_id, struct pt_regs *regs)
 {
 	/* NULL function - Does nothing */
 	return;
@@ -85,7 +87,7 @@
 	}
 	memcpy(tmp, &new, sizeof(struct parport));
 
-	if (new.irq != -1) {
+	if (new.irq != PARPORT_IRQ_NONE) {
 		if (request_irq(new.irq, parport_null_intr_func,
 			  SA_INTERRUPT, new.name, tmp) != 0) {
 			printk(KERN_INFO "%s: unable to claim IRQ %d\n", 
@@ -197,11 +199,10 @@
 				return NULL;
 			}
 		}
-		if (port->irq != -1) {
-			if (request_irq(port->irq, 
-							parport_null_intr_func,
-							SA_INTERRUPT, port->name,
-							port) != 0) {
+		if (port->irq != PARPORT_IRQ_NONE) {
+			if (request_irq(port->irq, parport_null_intr_func,
+					SA_INTERRUPT, port->name,
+					port) != 0) {
 				release_region(port->base, port->size);
 				if( port->modes & PARPORT_MODE_ECR )
 					release_region(port->base+0x400, 3);
@@ -213,7 +214,6 @@
 		port->flags &= ~PARPORT_FLAG_COMA;
 	}
 
-
 	tmp = kmalloc(sizeof(struct ppd), GFP_KERNEL);
 	tmp->name = (char *) name;
 	tmp->port = port;
@@ -251,8 +251,7 @@
 	port = dev->port;
 
 	if (port->cad == dev) {
-		printk(KERN_INFO "%s: refused to unregister currently active device %s\n",
-			   port->name, dev->name);
+		printk(KERN_INFO "%s: refused to unregister currently active device %s\n", port->name, dev->name);
 		return;
 	}
 
@@ -299,8 +298,9 @@
 			if (dev->port->modes & PARPORT_MODE_ECR)
 				dev->port->cad->ecr = dev->port->ecr = 
 					r_ecr(dev->port);
-			dev->port->cad->ctr = dev->port->ctr =
-				r_ctr(dev->port);
+			if (dev->port->modes & PARPORT_MODE_SPP)
+				dev->port->cad->ctr = dev->port->ctr =
+					r_ctr(dev->port);
 		} else
 			return -EAGAIN;
 	}
@@ -326,7 +326,8 @@
 	/* Restore control registers */
 	if (dev->port->modes & PARPORT_MODE_ECR)
 		if (dev->ecr != dev->port->ecr) w_ecr(dev->port, dev->ecr);
-	if (dev->ctr != dev->port->ctr) w_ctr(dev->port, dev->ctr);
+	if (dev->port->modes & PARPORT_MODE_SPP)
+		if (dev->ctr != dev->port->ctr) w_ctr(dev->port, dev->ctr);
 
 	return 0;
 }
@@ -337,8 +338,7 @@
 
 	/* Make sure that dev is the current device */
 	if (dev->port->cad != dev) {
-		printk(KERN_WARNING "%s: %s tried to release parport when not owner\n",
-			   dev->port->name, dev->name);
+		printk(KERN_WARNING "%s: %s tried to release parport when not owner\n", dev->port->name, dev->name);
 		return;
 	}
 	dev->port->cad = NULL;
@@ -346,12 +346,13 @@
 	/* Save control registers */
 	if (dev->port->modes & PARPORT_MODE_ECR)
 		dev->ecr = dev->port->ecr = r_ecr(dev->port);
-	dev->ctr = dev->port->ctr = r_ctr(dev->port);
+	if (dev->port->modes & PARPORT_MODE_SPP)
+		dev->ctr = dev->port->ctr = r_ctr(dev->port);
 	
 	if (dev->port->irq >= 0) {
 		free_irq(dev->port->irq, dev->port);
 		request_irq(dev->port->irq, parport_null_intr_func,
-					SA_INTERRUPT, dev->port->name, dev->port);
+			    SA_INTERRUPT, dev->port->name, dev->port);
  	}
 
 	/* Walk the list, offering a wakeup callback to everybody other
@@ -384,16 +385,22 @@
 	if (dev->port->lurker && (dev->port->lurker != dev)) {
 		if (dev->port->lurker->wakeup) {
 			dev->port->lurker->wakeup(dev->port->lurker->private);
-			return;
+		} 
+#ifdef PARPORT_PARANOID
+		else {  /* can't happen */
+			printk(KERN_DEBUG
+			  "%s (%s): lurker's wakeup callback went away!\n",
+			       dev->port->name, dev->name);
 		}
-		printk(KERN_DEBUG
-		       "%s (%s): lurker's wakeup callback went away!\n",
-		       dev->port->name, dev->name);
+#endif
 	}
 }
 
 /* The following read funktions are an implementation of a status readback
  * and device id request confirming to IEEE1284-1994.
+ *
+ * These probably ought to go in some seperate file, so people like the SPARC
+ * don't have to pull them in.
  */
 
 /* Wait for Status line(s) to change in 35 ms - see IEEE1284-1994 page 24 to

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov