diff -urN /mnt/disk/linux/drivers/net/hp.c /linux/drivers/net/hp.c --- /mnt/disk/linux/drivers/net/hp.c Fri Oct 13 21:40:06 2000 +++ /linux/drivers/net/hp.c Mon Oct 16 19:23:08 2000 @@ -94,13 +94,9 @@ else if (base_addr != 0) /* Don't probe at all. */ return -ENXIO; - for (i = 0; hppclan_portlist[i]; i++) { - int ioaddr = hppclan_portlist[i]; - if (check_region(ioaddr, HP_IO_EXTENT)) - continue; - if (hp_probe1(dev, ioaddr) == 0) + for (i = 0; hppclan_portlist[i]; i++) + if (hp_probe1(dev, hppclan_portlist[i]) == 0) return 0; - } return -ENODEV; } @@ -108,18 +104,23 @@ int __init hp_probe1(struct net_device *dev, int ioaddr) { - int i, board_id, wordmode; + int i, retval, board_id, wordmode; const char *name; static unsigned version_printed = 0; + if (!request_region(ioaddr, HP_IO_EXTENT, "hp")) + return -ENODEV; + /* 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 also! Avoid the lance 0x5757 signature. */ if (inb(ioaddr) != 0x08 || inb(ioaddr+1) != 0x00 || inb(ioaddr+2) != 0x09 - || inb(ioaddr+14) == 0x57) - return -ENODEV; + || inb(ioaddr+14) == 0x57) { + retval = -ENODEV; + goto out; + } /* Set up the parameters based on the board ID. If you have additional mappings, please mail them to me -djb. */ @@ -134,7 +135,7 @@ /* We should have a "dev" from Space.c or the static module table. */ if (dev == NULL) { printk("hp.c: Passed a NULL device.\n"); - dev = init_etherdev(0, 0); + BUG(); } if (ei_debug && version_printed++ == 0) @@ -143,7 +144,8 @@ /* 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; } printk("%s: %s (ID %02x) at %#3x,", dev->name, name, board_id, ioaddr); @@ -173,24 +175,19 @@ } while (*++irqp); if (*irqp == 0) { printk(" no free IRQ lines.\n"); - kfree(dev->priv); - dev->priv = NULL; - return -EBUSY; + retval = -EBUSY; + goto out1; } } else { if (dev->irq == 2) dev->irq = 9; if (request_irq(dev->irq, ei_interrupt, 0, "hp", dev)) { printk (" unable to get IRQ %d.\n", dev->irq); - kfree(dev->priv); - dev->priv = NULL; - return -EBUSY; + retval = -EBUSY; + goto out1; } } - /* Grab the region so we can find another board if something fails. */ - request_region(ioaddr, HP_IO_EXTENT,"hp"); - /* Set the base address to point to the NIC, not the "real" base! */ dev->base_addr = ioaddr + NIC_OFFSET; dev->open = &hp_open; @@ -209,6 +206,12 @@ hp_init_card(dev); return 0; +out1: + kfree(dev->priv); + dev->priv = NULL; +out: + release_region(ioaddr, HP_IO_EXTENT); + return retval; } static int