patch-2.4.0-test10 linux/drivers/net/3c507.c

Next file: linux/drivers/net/3c509.c
Previous file: linux/drivers/net/3c505.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test9/linux/drivers/net/3c507.c linux/drivers/net/3c507.c
@@ -295,11 +295,6 @@
 static void init_82586_mem(struct net_device *dev);
 
 
-#ifdef HAVE_DEVLIST
-struct netdev_entry netcard_drv =
-{"3c507", el16_probe1, EL16_IO_EXTENT, netcard_portlist};
-#endif
-
 /* Check for a network adaptor of this type, and return '0' iff one exists.
 	If dev->base_addr == 0, probe all likely locations.
 	If dev->base_addr == 1, always return failure.
@@ -317,13 +312,9 @@
 	else if (base_addr != 0)
 		return -ENXIO;		/* Don't probe at all. */
 
-	for (i = 0; netcard_portlist[i]; i++) {
-		int ioaddr = netcard_portlist[i];
-		if (check_region(ioaddr, EL16_IO_EXTENT))
-			continue;
-		if (el16_probe1(dev, ioaddr) == 0)
+	for (i = 0; netcard_portlist[i]; i++)
+		if (el16_probe1(dev, netcard_portlist[i]) == 0)
 			return 0;
-	}
 
 	return -ENODEV;
 }
@@ -331,7 +322,7 @@
 static int __init el16_probe1(struct net_device *dev, int ioaddr)
 {
 	static unsigned char init_ID_done = 0, version_printed = 0;
-	int i, irq, irqval;
+	int i, irq, irqval, retval;
 	struct net_local *lp;
 
 	if (init_ID_done == 0) {
@@ -348,15 +339,14 @@
 		init_ID_done = 1;
 	}
 
-	if (inb(ioaddr) == '*' && inb(ioaddr+1) == '3'
-		&& inb(ioaddr+2) == 'C' && inb(ioaddr+3) == 'O')
-		;
-	else
+	if (!request_region(ioaddr, EL16_IO_EXTENT, "3c507"))
 		return -ENODEV;
 
-	/* Allocate a new 'dev' if needed. */
-	if (dev == NULL)
-		dev = init_etherdev(0, 0);
+	if ((inb(ioaddr) != '*') || (inb(ioaddr + 1) != '3') || 
+	    (inb(ioaddr + 2) != 'C') || (inb(ioaddr + 3) != 'O')) {
+		retval = -ENODEV;
+		goto out;
+	}
 
 	if (net_debug  &&  version_printed++ == 0)
 		printk(version);
@@ -371,11 +361,11 @@
 	irqval = request_irq(irq, &el16_interrupt, 0, "3c507", dev);
 	if (irqval) {
 		printk ("unable to get IRQ %d (irqval=%d).\n", irq, irqval);
-		return -EAGAIN;
+		retval = -EAGAIN;
+		goto out;
 	}
 
 	/* We've committed to using the board, and can start filling in *dev. */
-	request_region(ioaddr, EL16_IO_EXTENT, "3c507");
 	dev->base_addr = ioaddr;
 
 	outb(0x01, ioaddr + MISC_CTRL);
@@ -419,8 +409,10 @@
 
 	/* Initialize the device structure. */
 	lp = dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
-	if (dev->priv == NULL)
-		return -ENOMEM;
+	if (dev->priv == NULL) {
+		retval = -ENOMEM;
+		goto out;
+	}
 	memset(dev->priv, 0, sizeof(struct net_local));
 	spin_lock_init(&lp->lock);
 
@@ -436,6 +428,9 @@
 	dev->flags&=~IFF_MULTICAST;	/* Multicast doesn't work */
 
 	return 0;
+out:
+	release_region(ioaddr, EL16_IO_EXTENT);
+	return retval;
 }
 
 static int el16_open(struct net_device *dev)
@@ -862,12 +857,7 @@
 	lp->rx_tail = rx_tail;
 }
 #ifdef MODULE
-static struct net_device dev_3c507 = {
-	"", /* device name is inserted by linux/drivers/net/net_init.c */
-	0, 0, 0, 0,
-	0, 0,
-	0, 0, 0, NULL, el16_probe
-};
+static struct net_device dev_3c507 = { init: el16_probe };
 
 static int io = 0x300;
 static int irq = 0;

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