diff -urN /mnt/disk/linux/drivers/net/ne.c /linux/drivers/net/ne.c --- /mnt/disk/linux/drivers/net/ne.c Thu Nov 2 22:00:58 2000 +++ /linux/drivers/net/ne.c Mon Nov 6 19:14:49 2000 @@ -133,7 +133,7 @@ #define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ /* Non-zero only if the current card is a PCI with BIOS-set IRQ. */ -static unsigned int pci_irq_line = 0; +static unsigned int pci_irq_line; int ne_probe(struct net_device *dev); static int ne_probe1(struct net_device *dev, int ioaddr); @@ -204,13 +204,9 @@ #ifndef MODULE /* Last resort. The semi-risky ISA auto-probe. */ - for (base_addr = 0; netcard_portlist[base_addr] != 0; base_addr++) { - int ioaddr = netcard_portlist[base_addr]; - if (check_region(ioaddr, NE_IO_EXTENT)) - continue; - if (ne_probe1(dev, ioaddr) == 0) + for (base_addr = 0; netcard_portlist[base_addr] != 0; base_addr++) + if (ne_probe1(dev, netcard_portlist[base_addr]) == 0) return 0; - } #endif return -ENODEV; @@ -229,9 +225,6 @@ if (pci_enable_device(pdev)) continue; pci_ioaddr = pci_resource_start (pdev, 0); - /* Avoid already found cards from previous calls */ - if (check_region(pci_ioaddr, NE_IO_EXTENT)) - continue; pci_irq_line = pdev->irq; if (pci_irq_line) break; /* Found it */ } @@ -295,17 +288,22 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) { - int i; + int i, retval; unsigned char SA_prom[32]; int wordlength = 2; const char *name = NULL; int start_page, stop_page; int neX000, ctron, copam, bad_card; - int reg0 = inb_p(ioaddr); - static unsigned version_printed = 0; + int reg0; + static unsigned version_printed; + + if (!request_region(ioaddr, NE_IO_EXTENT, dev->name)) + return -EBUSY; - if (reg0 == 0xFF) - return -ENODEV; + if ((reg0 = inb_p(ioaddr)) == 0xFF) { + retval = -ENODEV; + goto out; + } /* Do a preliminary verification that we have a 8390. */ { @@ -318,7 +316,8 @@ if (inb_p(ioaddr + EN0_COUNTER0) != 0) { outb_p(reg0, ioaddr); outb_p(regd, ioaddr + 0x0d); /* Restore the old values. */ - return -ENODEV; + retval = -ENODEV; + goto out; } } @@ -350,7 +349,8 @@ break; } else { printk(" not found (no reset ack).\n"); - return -ENODEV; + retval = -ENODEV; + goto out; } } @@ -452,11 +452,13 @@ { printk(" not found (invalid signature %2.2x %2.2x).\n", SA_prom[14], SA_prom[15]); - return -ENXIO; + retval = -ENXIO; + goto out; } #else printk(" not found.\n"); - return -ENXIO; + retval = -ENXIO; + goto out; #endif } @@ -482,31 +484,30 @@ if (! dev->irq) { printk(" failed to detect IRQ line.\n"); - return -EAGAIN; + retval = -EAGAIN; + goto out; } /* 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. */ - - { - int irqval = request_irq(dev->irq, ei_interrupt, - pci_irq_line ? SA_SHIRQ : 0, name, dev); - if (irqval) { - printk (" unable to get IRQ %d (irqval=%d).\n", dev->irq, irqval); - kfree(dev->priv); - dev->priv = NULL; - return -EAGAIN; - } + retval = request_irq(dev->irq, ei_interrupt, + pci_irq_line ? SA_SHIRQ : 0, dev->name, dev); + if (retval) { + printk (" unable to get IRQ %d (irqval=%d).\n", dev->irq, retval); + kfree(dev->priv); + dev->priv = NULL; + goto out; } + dev->base_addr = ioaddr; - request_region(ioaddr, NE_IO_EXTENT, name); for(i = 0; i < ETHER_ADDR_LEN; i++) { printk(" %2.2x", SA_prom[i]); @@ -536,6 +537,9 @@ dev->stop = &ne_close; NS8390_init(dev, 0); return 0; +out: + release_region(ioaddr, NE_IO_EXTENT); + return retval; } static int ne_open(struct net_device *dev)