Skip to contentSkip to conversation

net drivers check_region() removal continues

PATCH New Andrey Panin 1 participant 1 message Nov 8, 2000

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net drivers check_region() removal continues

Hi all,

lots of patches attached:
3c503.c, ac3200.c, cs89x0.c, e2100.c, hp.c, hp-plus.c, lne390.c, ne.c, wd.c

Best regards,
Andrey

linux/drivers/net/3c503.c renamed from mnt/disk/linux/drivers/net/3c503.c +26 -22
diff -urN /mnt/disk/linux/drivers/net/3c503.c /linux/drivers/net/3c503.c
@@ -101,8 +101,6 @@
 		break;
 	if (base_bits != 1)
 	    continue;
-	if (check_region(netcard_portlist[i], EL2_IO_EXTENT))
-	    continue;
 	if (el2_probe1(dev, netcard_portlist[i]) == 0)
 	    return 0;
     }
@@ -126,13 +124,9 @@
     else if (base_addr != 0)	/* Don't probe at all. */
 	return -ENXIO;
 
-    for (i = 0; netcard_portlist[i]; i++) {
-	int ioaddr = netcard_portlist[i];
-	if (check_region(ioaddr, EL2_IO_EXTENT))
-	    continue;
-	if (el2_probe1(dev, ioaddr) == 0)
+    for (i = 0; netcard_portlist[i]; i++)
+	if (el2_probe1(dev, netcard_portlist[i]) == 0)
 	    return 0;
-    }
 
     return -ENODEV;
 }
@@ -143,14 +137,18 @@
 int __init 
 el2_probe1(struct net_device *dev, int ioaddr)
 {
-    int i, iobase_reg, membase_reg, saved_406, wordlength;
-    static unsigned version_printed = 0;
+    int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
+    static unsigned version_printed;
     unsigned long vendor_id;
 
+    if (!request_region(ioaddr, EL2_IO_EXTENT, dev->name))
+	return -EBUSY;
+
     /* Reset and/or avoid any lurking NE2000 */
     if (inb(ioaddr + 0x408) == 0xff) {
     	mdelay(1);
-	return -ENODEV;
+	retval = -ENODEV;
+	goto out;
     }
 
     /* We verify that it's a 3C503 board by checking the first three octets
@@ -160,7 +158,8 @@
     /* ASIC location registers should be 0 or have only a single bit set. */
     if (   (iobase_reg  & (iobase_reg - 1))
 	|| (membase_reg & (membase_reg - 1))) {
-	return -ENODEV;
+	retval = -ENODEV;
+	goto out;
     }
     saved_406 = inb_p(ioaddr + 0x406);
     outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
@@ -172,7 +171,8 @@
     if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) {
 	/* Restore the register we frobbed. */
 	outb(saved_406, ioaddr + 0x406);
-	return -ENODEV;
+	retval = -ENODEV;
+	goto out;
     }
 
     if (ei_debug  &&  version_printed++ == 0)
@@ -182,8 +182,9 @@
     /* Allocate dev->priv and fill in 8390 specific dev fields. */
     if (ethdev_init(dev)) {
 	printk ("3c503: unable to allocate memory for dev->priv.\n");
-	return -ENOMEM;
-     }
+	retval = -ENOMEM;
+	goto out;
+    }
 
     printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
 
@@ -282,8 +283,6 @@
     ei_status.block_input = &el2_block_input;
     ei_status.block_output = &el2_block_output;
 
-    request_region(ioaddr, EL2_IO_EXTENT, ei_status.name);
-
     if (dev->irq == 2)
 	dev->irq = 9;
     else if (dev->irq > 5 && dev->irq != 9) {
@@ -310,11 +309,15 @@
 	       dev->name, ei_status.name, (wordlength+1)<<3);
     }
     return 0;
+out:
+    release_region(ioaddr, EL2_IO_EXTENT);
+    return retval;
 }
 
 static int
 el2_open(struct net_device *dev)
 {
+    int retval = -EAGAIN;
 
     if (dev->irq < 2) {
 	int irqlist[] = {5, 9, 3, 4, 0};
@@ -327,18 +330,19 @@
 		autoirq_setup(0);
 		outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
 		outb_p(0x00, E33G_IDCFR);
-		if (*irqp == autoirq_report(0)	 /* It's a good IRQ line! */
-		    && request_irq (dev->irq = *irqp, ei_interrupt, 0, ei_status.name, dev) == 0)
+		if (*irqp == autoirq_report(0)	/* It's a good IRQ line! */
+		    && ((retval = request_irq(dev->irq = *irqp, 
+		    ei_interrupt, 0, dev->name, dev)) == 0))
 		    break;
 	    }
 	} while (*++irqp);
 	if (*irqp == 0) {
 	    outb(EGACFR_IRQOFF, E33G_GACFR);	/* disable interrupts. */
-	    return -EAGAIN;
+	    return retval;
 	}
     } else {
-	if (request_irq(dev->irq, ei_interrupt, 0, ei_status.name, dev)) {
-	    return -EAGAIN;
+	if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
+	    return retval;
 	}
     }
 
linux/drivers/net/ac3200.c renamed from mnt/disk/linux/drivers/net/ac3200.c +7 -6
diff -urN /mnt/disk/linux/drivers/net/ac3200.c /linux/drivers/net/ac3200.c
@@ -121,8 +118,8 @@
 {
 	int i, retval;
 
-	if (!request_region(ioaddr, AC_IO_EXTENT, "ac3200"))
-		return -ENODEV;
+	if (!request_region(ioaddr, AC_IO_EXTENT, dev->name))
+		return -EBUSY;
 
 	if (inb_p(ioaddr + AC_ID_PORT) == 0xff) {
 		retval = -ENODEV;
@@ -172,9 +169,8 @@
 		printk(", assigning");
 	}
 
-	if (request_irq(dev->irq, ei_interrupt, 0, "ac3200", dev)) {
+	if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
 		printk (" nothing! Unable to get IRQ %d.\n", dev->irq);
-		retval = -EAGAIN;
 		goto out1;
 	}
 
@@ -260,11 +256,13 @@
 static int ac_open(struct net_device *dev)
 {
 #ifdef notyet
+	int retval;
+
 	/* Someday we may enable the IRQ and shared memory here. */
 	int ioaddr = dev->base_addr;
 
-	if (request_irq(dev->irq, ei_interrupt, 0, "ac3200", dev))
-		return -EAGAIN;
+	if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev)))
+		return retval;
 #endif
 
 	ei_open(dev);
linux/drivers/net/cs89x0.c renamed from mnt/disk/linux/drivers/net/cs89x0.c +6 -6
diff -urN /mnt/disk/linux/drivers/net/cs89x0.c /linux/drivers/net/cs89x0.c
@@ -378,8 +378,8 @@
 	lp = (struct net_local *)dev->priv;
 
 	/* Grab the region so we can find another board if autoIRQ fails. */
-	if (!request_region(ioaddr, NETCARD_IO_EXTENT, "cs89x0")) {
-		retval = -ENODEV;
+	if (!request_region(ioaddr, NETCARD_IO_EXTENT, dev->name)) {
+		retval = -EBUSY;
 		goto out1;
 	}
 
@@ -1028,10 +1028,10 @@
 		writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON);
 
 		for (i = 2; i < CS8920_NO_INTS; i++) if ((1 << dev->irq) & lp->irq_map) {
-			if (request_irq (i, NULL, 0, "cs89x0", dev) != -EBUSY) {
+			if (request_irq (i, NULL, 0, dev->name, dev) != -EBUSY) {
 				write_irq(dev, lp->chip_type, i);
 				writereg(dev, PP_BufCFG, GENERATE_SW_INTERRUPT);
-				if (request_irq (dev->irq = i, &net_interrupt, 0, "cs89x0", dev) == 0)
+				if (request_irq (dev->irq = i, &net_interrupt, 0, dev->name, dev) == 0)
 					break;
 			}
 		}
@@ -1058,7 +1058,7 @@
 		writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON);
 #endif
 		write_irq(dev, lp->chip_type, dev->irq);
-		if (request_irq(dev->irq, &net_interrupt, 0, "cs89x0", dev)) {
+		if (request_irq(dev->irq, &net_interrupt, 0, dev->name, dev)) {
 			if (net_debug)
 				printk("cs89x0: request_irq(%d) failed\n", dev->irq);
 			ret = -EAGAIN;
@@ -1089,7 +1089,7 @@
 				goto release_irq;
 			}
 			memset(lp->dma_buff, 0, lp->dmasize * 1024);	/* Why? */
-			if (request_dma(dev->dma, "cs89x0")) {
+			if (request_dma(dev->dma, dev->name)) {
 				printk(KERN_ERR "%s: cannot get dma channel %d\n", dev->name, dev->dma);
 				goto release_irq;
 			}
linux/drivers/net/e2100.c renamed from mnt/disk/linux/drivers/net/e2100.c +5 -5
diff -urN /mnt/disk/linux/drivers/net/e2100.c /linux/drivers/net/e2100.c
@@ -140,8 +140,8 @@
 	unsigned char *station_addr = dev->dev_addr;
 	static unsigned version_printed = 0;
 
-	if (!request_region(ioaddr, E21_IO_EXTENT, "e2100"))
-		return -ENODEV;
+	if (!request_region(ioaddr, E21_IO_EXTENT, dev->name))
+		return -EBUSY;
 
 	/* First check the station address for the Ctron prefix. */
 	if (inb(ioaddr + E21_SAPROM + 0) != 0x00
@@ -255,10 +255,10 @@
 e21_open(struct net_device *dev)
 {
 	short ioaddr = dev->base_addr;
+	int retval;
 
-	if (request_irq(dev->irq, ei_interrupt, 0, "e2100", dev)) {
-		return -EBUSY;
-	}
+	if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev)))
+		return retval;
 
 	/* Set the interrupt line and memory base on the hardware. */
 	inb(ioaddr + E21_IRQ_LOW);
linux/drivers/net/hp.c renamed from mnt/disk/linux/drivers/net/hp.c +5 -6
diff -urN /mnt/disk/linux/drivers/net/hp.c /linux/drivers/net/hp.c
@@ -101,10 +101,10 @@
 {
 	int i, retval, board_id, wordmode;
 	const char *name;
-	static unsigned version_printed = 0;
+	static unsigned version_printed;
 
-	if (!request_region(ioaddr, HP_IO_EXTENT, "hp"))
-		return -ENODEV;
+	if (!request_region(ioaddr, HP_IO_EXTENT, dev->name))
+		return -EBUSY;
 
 	/* Check for the HP physical address, 08 00 09 xx xx xx. */
 	/* This really isn't good enough: we may pick up HP LANCE boards
@@ -155,7 +155,7 @@
 				outb_p(irqmap[irq] | HP_RUN, ioaddr + HP_CONFIGURE);
 				outb_p( 0x00 | HP_RUN, ioaddr + HP_CONFIGURE);
 				if (irq == autoirq_report(0)		 /* It's a good IRQ line! */
-					&& request_irq (irq, ei_interrupt, 0, "hp", dev) == 0) {
+					&& request_irq (irq, ei_interrupt, 0, dev->name, dev) == 0) {
 					printk(" selecting IRQ %d.\n", irq);
 					dev->irq = *irqp;
 					break;
@@ -170,9 +170,8 @@
 	} else {
 		if (dev->irq == 2)
 			dev->irq = 9;
-		if (request_irq(dev->irq, ei_interrupt, 0, "hp", dev)) {
+		if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
 			printk (" unable to get IRQ %d.\n", dev->irq);
-			retval = -EBUSY;
 			goto out1;
 		}
 	}
linux/drivers/net/hp-plus.c renamed from mnt/disk/linux/drivers/net/hp-plus.c +6 -5
diff -urN /mnt/disk/linux/drivers/net/hp-plus.c /linux/drivers/net/hp-plus.c
@@ -141,10 +141,10 @@
 	unsigned char checksum = 0;
 	const char *name = "HP-PC-LAN+";
 	int mem_start;
-	static unsigned version_printed = 0;
+	static unsigned version_printed;
 
-	if (!request_region(ioaddr, HP_IO_EXTENT, "hp-plus"))
-		return -ENODEV;
+	if (!request_region(ioaddr, HP_IO_EXTENT, dev->name))
+		return -EBUSY;
 
 	/* Check for the HP+ signature, 50 48 0x 53. */
 	if (inw(ioaddr + HP_ID) != 0x4850
@@ -249,9 +249,10 @@
 {
 	int ioaddr = dev->base_addr - NIC_OFFSET;
 	int option_reg;
+	int retval;
 
-	if (request_irq(dev->irq, ei_interrupt, 0, "hp-plus", dev)) {
-	    return -EAGAIN;
+	if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
+	    return retval;
 	}
 
 	/* Reset the 8390 and HP chip. */
linux/drivers/net/lne390.c renamed from mnt/disk/linux/drivers/net/lne390.c +4 -4
diff -urN /mnt/disk/linux/drivers/net/lne390.c /linux/drivers/net/lne390.c
@@ -109,7 +109,7 @@
 	int ret;
 
 	if (ioaddr > 0x1ff) {		/* Check a single specified location. */
-		if (!request_region(ioaddr, LNE390_IO_EXTENT, "lne390"))
+		if (!request_region(ioaddr, LNE390_IO_EXTENT, dev->name))
 			return -EBUSY;
 		ret = lne390_probe1(dev, ioaddr);
 		if (ret)
@@ -128,7 +128,7 @@
 
 	/* EISA spec allows for up to 16 slots, but 8 is typical. */
 	for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
-		if (!request_region(ioaddr, LNE390_IO_EXTENT, "lne390"))
+		if (!request_region(ioaddr, LNE390_IO_EXTENT, dev->name))
 			continue;
 		if (lne390_probe1(dev, ioaddr) == 0)
 			return 0;
@@ -195,11 +195,11 @@
 	}
 	printk(" IRQ %d,", dev->irq);
 
-	if (request_irq(dev->irq, ei_interrupt, 0, "lne390", dev)) {
+	if ((ret = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
 		printk (" unable to get IRQ %d.\n", dev->irq);
 		kfree(dev->priv);
 		dev->priv = NULL;
-		return -EAGAIN;
+		return ret;
 	}
 
 	if (dev->mem_start == 0) {
linux/drivers/net/ne.c renamed from mnt/disk/linux/drivers/net/ne.c +36 -32

144 lines not on this page · raw message

linux/drivers/net/wd.c renamed from mnt/disk/linux/drivers/net/wd.c +18 -15
diff -urN /mnt/disk/linux/drivers/net/wd.c /linux/drivers/net/wd.c
@@ -91,32 +91,33 @@
 	else if (base_addr != 0)	/* Don't probe at all. */
 		return -ENXIO;
 
-	for (i = 0; wd_portlist[i]; i++) {
-		int ioaddr = wd_portlist[i];
-		if (check_region(ioaddr, WD_IO_EXTENT))
-			continue;
-		if (wd_probe1(dev, ioaddr) == 0)
+	for (i = 0; wd_portlist[i]; i++)
+		if (wd_probe1(dev, wd_portlist[i]) == 0)
 			return 0;
-	}
 
 	return -ENODEV;
 }
 
 static int __init wd_probe1(struct net_device *dev, int ioaddr)
 {
-	int i;
+	int i, retval;
 	int checksum = 0;
 	int ancient = 0;			/* An old card without config registers. */
 	int word16 = 0;				/* 0 = 8 bit, 1 = 16 bit */
 	const char *model_name;
-	static unsigned version_printed = 0;
+	static unsigned version_printed;
+
+	if (!request_region(ioaddr, WD_IO_EXTENT, dev->name))
+		return -EBUSY;
 
 	for (i = 0; i < 8; i++)
 		checksum += inb(ioaddr + 8 + i);
 	if (inb(ioaddr + 8) == 0xff 	/* Extra check to avoid soundcard. */
 		|| inb(ioaddr + 9) == 0xff
-		|| (checksum & 0xff) != 0xFF)
-		return -ENODEV;
+		|| (checksum & 0xff) != 0xFF) {
+		retval = -ENODEV;
+		goto out;
+	}
 
 	/* Check for semi-valid mem_start/end values if supplied. */
 	if ((dev->mem_start % 0x2000) || (dev->mem_end % 0x2000)) {
@@ -243,21 +244,20 @@
 	/* Allocate dev->priv and fill in 8390 specific dev fields. */
 	if (ethdev_init(dev)) {
 		printk (" unable to get memory for dev->priv.\n");
-		return -ENOMEM;
+		retval = -ENOMEM;
+		goto out;
 	}
 
 	/* Snarf the interrupt now.  There's no point in waiting since we cannot
 	   share and the board will usually be enabled. */
-	if (request_irq(dev->irq, ei_interrupt, 0, model_name, dev)) {
+	if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
 		printk (" unable to get IRQ %d.\n", dev->irq);
 		kfree(dev->priv);
 		dev->priv = NULL;
-		return -EAGAIN;
+		goto out;
 	}
 
 	/* OK, were are certain this is going to work.  Setup the device. */
-	request_region(ioaddr, WD_IO_EXTENT, model_name);
-
 	ei_status.name = model_name;
 	ei_status.word16 = word16;
 	ei_status.tx_start_page = WD_START_PG;
@@ -294,6 +294,9 @@
 #endif
 
 	return 0;
+out:
+	release_region(ioaddr, WD_IO_EXTENT);
+	return retval;
 }
 
 static int