Re: [PATCH] NIC drivers check_region() removal continues
Andrey Panin wrote: > > Hi all, > > new net drivers patchset (against 2.4.0-test11-pre1) attached. > > Modifications: check_region() removal, passing dev->name to > request_region() & request_irq() etc. > > Drivers affected: 3c501.c, 3c503.c, 3c505.c, 82596.c, eth16i.c, hp.c, > hp-plus.c, ibmlana.c, ne2.c, seeq8005.c, smc-mca.c, smc-ultra.c, > smc-ultra32.c Most patches applied, thanks. Comments: 3c505.c: You must abort if dma_mem_alloc return value is null, not just print a message. 82596.c: Not applied. My moving the "if checksum & 0x100" line, you make the code comments incorrect. eth16i.c: Your diff was not created in the main linux directory... seeq8005.c: Applied, but you forgot dev->name in request_region -- Jeff Garzik | Building 1024 | Would you like a Twinkie? MandrakeSoft| - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
[PATCH] NIC drivers check_region() removal continues
Hi all, new net drivers patchset (against 2.4.0-test11-pre1) attached. Modifications: check_region() removal, passing dev->name to request_region() & request_irq() etc. Drivers affected: 3c501.c, 3c503.c, 3c505.c, 82596.c, eth16i.c, hp.c, hp-plus.c, ibmlana.c, ne2.c, seeq8005.c, smc-mca.c, smc-ultra.c, smc-ultra32.c Best regard, Andrey -- Andrey Panin| Embedded systems software engineer [EMAIL PROTECTED]| PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc diff -urN /mnt/disk/linux/drivers/net/3c501.c /linux/drivers/net/3c501.c --- /mnt/disk/linux/drivers/net/3c501.c Thu Nov 2 22:00:58 2000 +++ /linux/drivers/net/3c501.c Sat Nov 4 21:22:59 2000 @@ -398,6 +398,7 @@ static int el_open(struct net_device *dev) { + int retval; int ioaddr = dev->base_addr; struct net_local *lp = (struct net_local *)dev->priv; unsigned long flags; @@ -407,9 +408,9 @@ if (el_debug > 2) printk("%s: Doing el_open()...", dev->name); - if (request_irq(dev->irq, &el_interrupt, 0, "3c501", dev)) { + if ((retval = request_irq(dev->irq, &el_interrupt, 0, dev->name, dev))) { MOD_DEC_USE_COUNT; - return -EAGAIN; + return retval; } spin_lock_irqsave(&lp->lock, flags); 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 diff -urN /mnt/disk/linux/drivers/net/3c505.c /linux/drivers/net/3c505.c --- /mnt/disk/linux/drivers/net/3c505.c Thu Nov 9 21:28:06 2000 +++ /linux/drivers/net/3c505.c Thu Nov 9 22:58:51 2000 @@ -854,6 +854,7 @@ static int elp_open(struct net_device *dev) { elp_device *adapter; + int retval; adapter = dev->priv; @@ -893,16 +894,17 @@ /* * install our interrupt service routine */ - if (request_irq(dev->irq, &elp_interrupt, 0, "3c505", dev)) { - return -EAGAIN; + if ((retval = request_irq(dev->irq, &el
[PATCH] NIC drivers: check_region() removal continues
Hi all, check_region() removal continues ... Affected drivers: hp.c, hp-plus.c, es3210.c, e2100.c, 3c505.c Best regards, Andrey -- Andrey Panin| Embedded systems software engineer [EMAIL PROTECTED]| PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc diff -urN /mnt/disk/linux/drivers/net/hp.c /linux/drivers/net/hp.c --- /mnt/disk/linux/drivers/net/hp.cFri 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 diff -urN /mnt/disk/linux/drivers/net/hp-plus.c /linux/drivers/net/hp-plus.c --- /mnt/disk/linux/drivers/net/hp-plus.c Fri Oct 13 21:40:06 2000 +++ /linux/drivers/net/hp-plus.cMon Oct 16 19:16:49 2000 @@ -133,13 +133,9 @@ else if (base_addr != 0)/* Don't probe at all. */ return -ENXIO; - for (i = 0; hpplus_portlist[i]; i++) { - int ioaddr = hpplus_portlist[i]; - if (check_region(ioaddr, HP_IO_EXTENT)) - continue; - if (hpp_probe1(dev, ioaddr) == 0) + for (i = 0; hpplus_portlist[i]; i++) + if (hpp_probe1(dev, hpplus_portlist[i]) == 0) return 0; - } return -ENODEV; } @@ -148,21 +144,26 @@ /* Do the interesting part of the probe at a single address. */ int __init hpp_probe1(struct net_device *dev, int ioaddr) { - int i; + int i, retval; unsigned char checksum = 0; const char *name = "H