diff -urN /mnt/disk/linux/drivers/net/3c503.c /linux/drivers/net/3c503.c --- /mnt/disk/linux/drivers/net/3c503.c Thu Nov 2 22:00:58 2000 +++ /linux/drivers/net/3c503.c Sat Nov 4 18:58:39 2000 @@ -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,6 +309,9 @@ dev->name, ei_status.name, (wordlength+1)<<3); } return 0; +out: + release_region(ioaddr, EL2_IO_EXTENT); + return retval; } static int