patch-2.4.0-test11 linux/drivers/net/ne2.c

Next file: linux/drivers/net/ne2k-pci.c
Previous file: linux/drivers/net/ne.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test10/linux/drivers/net/ne2.c linux/drivers/net/ne2.c
@@ -200,12 +200,12 @@
 
 static int __init ne2_probe1(struct net_device *dev, int slot)
 {
-	int i, base_addr, irq;
+	int i, base_addr, irq, retval;
 	unsigned char POS;
 	unsigned char SA_prom[32];
 	const char *name = "NE/2";
 	int start_page, stop_page;
-	static unsigned version_printed = 0;
+	static unsigned version_printed;
 
 	if (ei_debug && version_printed++ == 0)
 		printk(version);
@@ -226,6 +226,9 @@
 	base_addr = addresses[i - 1];
 	irq = irqs[(POS & 0x60)>>5];
 
+	if (!request_region(base_addr, NE_IO_EXTENT, dev->name))
+		return -EBUSY;
+
 #ifdef DEBUG
 	printk("POS info : pos 2 = %#x ; base = %#x ; irq = %ld\n", POS,
 			base_addr, irq);
@@ -239,7 +242,8 @@
 	outb(0x21, base_addr + NE_CMD);
 	if (inb(base_addr + NE_CMD) != 0x21) {
 		printk("NE/2 adapter not responding\n");
-		return -ENODEV;
+		retval = -ENODEV;
+		goto out;
 	}
 
 	/* In the crynwr sources they do a RAM-test here. I skip it. I suppose
@@ -260,7 +264,8 @@
 		while ((inb_p(base_addr + EN0_ISR) & ENISR_RESET) == 0)
 			if (jiffies - reset_start_time > 2*HZ/100) {
 				printk(" not found (no reset ack).\n");
-				return -ENODEV;
+				retval = -ENODEV;
+				goto out;
 			}
 
 		outb_p(0xff, base_addr + EN0_ISR);         /* Ack all intr. */
@@ -309,14 +314,11 @@
 
 	/* Snarf the interrupt now.  There's no point in waiting since we cannot
 	   share and the board will usually be enabled. */
-	{
-		int irqval = request_irq(dev->irq, ei_interrupt, 
-				0, name, dev);
-		if (irqval) {
-			printk (" unable to get IRQ %d (irqval=%d).\n", 
-					dev->irq, +irqval);
-			return -EAGAIN;
-		}
+	retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev);
+	if (retval) {
+		printk (" unable to get IRQ %d (irqval=%d).\n", 
+				dev->irq, retval);
+		goto out;
 	}
 
 	dev->base_addr = base_addr;
@@ -325,11 +327,10 @@
 	if (ethdev_init(dev)) {
 		printk (" unable to get memory for dev->priv.\n");
 		free_irq(dev->irq, dev);
-		return -ENOMEM;
+		retval = -ENOMEM;
+		goto out;
 	}
 
-	request_region(base_addr, NE_IO_EXTENT, name);
-
 	for(i = 0; i < ETHER_ADDR_LEN; i++) {
 		printk(" %2.2x", SA_prom[i]);
 		dev->dev_addr[i] = SA_prom[i];
@@ -362,6 +363,9 @@
 	dev->stop = &ne_close;
 	NS8390_init(dev, 0);
 	return 0;
+out:
+	release_region(base_addr, NE_IO_EXTENT);
+	return retval;
 }
 
 static int ne_open(struct net_device *dev)

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