NIC drivers check_region() removal continues
PATCH 1/1 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
Signature · 2 lines
Andrey Panin | Embedded systems software engineer [email protected] | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc
linux/drivers/net/3c501.c renamed from mnt/disk/linux/drivers/net/3c501.c +3 -2
@@ -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);
linux/drivers/net/3c503.c renamed from mnt/disk/linux/drivers/net/3c503.c +19 -17
@@ -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
linux/drivers/net/3c505.c renamed from mnt/disk/linux/drivers/net/3c505.c +8 -6
@@ -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, &elp_interrupt,0 , dev->name, dev))) { +printk ("%s: could not allocate IRQ%d\n" , dev->name, dev->irq); +return retval; } -if (request_dma (dev->dma,"3c505" )) { -printk ("%s: could not allocate DMA channel\n" , dev->name); -return -EAGAIN ; +if ((retval =request_dma (dev->dma, dev->name))) { +printk ("%s: could not allocate DMA%d channel\n" , dev->name, dev->dma); +return retval; } adapter->dma_buffer = (void *)dma_mem_alloc (DMA_BUFFER_SIZE );if (!adapter->dma_buffer) { -printk ("Could not allocate DMA buffer\n" ); +printk ("%s: could not allocate DMA buffer\n" , dev->name); } adapter->dmaing =0 ;
linux/drivers/net/82596.c renamed from mnt/disk/linux/drivers/net/82596.c +7 -10
@@ -1093,7 +1093,7 @@int i;struct i596_private *lp;char eth_addr[6 ]; -static int probed =0 ; +static int probed;if (probed)return -ENODEV ;
@@ -1131,9 +1131,9 @@/* this is easy the ethernet interface can only be at 0x300 */ /* first check nothing is already registered here */ -if (check_region (ioaddr,I596_TOTAL_SIZE )) { +if (!request_region (ioaddr,I596_TOTAL_SIZE , dev->name)) {printk ("82596: IO address 0x%04x in use\n" , ioaddr); -return -ENODEV ; +return -EBUSY ; }for (i =0 ; i <8 ; i++) {
@@ -1145,17 +1145,14 @@some machines have 0x100, some 0x200. The DOS driver doesn't even bother with the checksum */ -if (checksum %0x100 ) -return -ENODEV ; -/* Some other boards trip the checksum.. but then appear as * ether address 0. Trap these - AC */ -if (memcmp (eth_addr,"\x00\x00\x49" ,3 ) !=0 ) -return -ENODEV ; - -if (!request_region (ioaddr,I596_TOTAL_SIZE ,"i596" )) +if ((checksum %0x100 ) || + (memcmp (eth_addr,"\x00\x00\x49" ,3 ) !=0 )) { +release_region (ioaddr,I596_TOTAL_SIZE );return -ENODEV ; + } dev->base_addr = ioaddr; dev->irq =10 ;
eth16i.c renamed from eth16i.c.orig +27 -20
102 lines not on this page · raw message
linux/drivers/net/hp.c renamed from mnt/disk/linux/drivers/net/hp.c +4 -5
@@ -101,9 +101,9 @@ {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" )) +if (!request_region (ioaddr,HP_IO_EXTENT , dev->name))return -ENODEV ;/* Check for the HP physical address, 08 00 09 xx xx xx. */
@@ -155,7 +155,7 @@outb_p (irqmap[irq] |HP_RUN , ioaddr +HP_CONFIGURE );outb_p (0x00 |HP_RUN , ioaddr +HP_CONFIGURE );if (irq ==probe_irq_off (cookie)/* 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
@@ -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/ibmlana.c renamed from mnt/disk/linux/drivers/net/ibmlana.c +14 -24
@@ -857,7 +857,7 @@ result =request_irq (priv->realirq, irq_handler, -SA_SHIRQ |SA_SAMPLE_RANDOM ,"ibm_lana" , dev); +SA_SHIRQ |SA_SAMPLE_RANDOM , dev->name, dev);if (result !=0 ) {printk ("%s: failed to register irq %d\n" , dev->name, dev->irq);
@@ -1046,7 +1046,7 @@/* can't work without an MCA bus ;-) */ if (MCA_bus ==0 ) -return ENODEV ; +return -ENODEV ;/* start address of 1 --> forced detection */
@@ -1101,19 +1101,18 @@/* nothing found ? */ if (slot ==-1 ) -return ((base !=0 ) || (irq !=0 )) ?ENXIO :ENODEV ; +return ((base !=0 ) || (irq !=0 )) ? -ENXIO : -ENODEV ;/* announce success */ printk ("%s: IBM LAN Adapter/A found in slot %d\n" , dev->name, slot +1 );/* try to obtain I/O range */ -if (check_region (iobase,IBM_LANA_IORANGE ) <0 ) { -printk ("cannot allocate I/O range at %#x!\n" , iobase); +if (!request_region (iobase,IBM_LANA_IORANGE , dev->name)) { +printk ("%s: cannot allocate I/O range at %#x!\n" , dev->name, iobase); startslot = slot +1 ; -return 0 ; +return -EBUSY ; } -request_region (iobase,IBM_LANA_IORANGE ,"ibm_lana" );/* make procfs entries */
@@ -1128,6 +1127,10 @@ priv = dev->priv = (ibmlana_priv *)kmalloc (sizeof (ibmlana_priv),GFP_KERNEL ); +if (!priv) { +release_region (iobase,IBM_LANA_IORANGE ); +return -ENOMEM ; + } priv->slot = slot; priv->realirq = irq; priv->medium = medium;
@@ -1189,24 +1192,11 @@#define DEVMAX 5 -#if (LINUX_VERSION_CODE >=0x020363 ) -static struct IBMLANA_NETDEV moddevs[DEVMAX ] = - { {" " ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe}, -{" " ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe}, -{" " ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe}, -{" " ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe}, -{" " ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe} -}; -#else -static char NameSpace[8 *DEVMAX ]; -static struct IBMLANA_NETDEV moddevs[DEVMAX ] = - { {NameSpace +0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe}, -{NameSpace +8 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe}, -{NameSpace +16 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe}, -{NameSpace +24 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe}, -{NameSpace +32 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,NULL , ibmlana_probe} +static struct IBMLANA_NETDEV moddevs[DEVMAX ] = { + { init: ibmlana_probe }, { init: ibmlana_probe }, + { init: ibmlana_probe }, { init: ibmlana_probe }, + { init: ibmlana_probe } }; -#endif int irq =0 ;int io =0 ;
linux/drivers/net/ne2.c renamed from mnt/disk/linux/drivers/net/ne2.c +19 -15
@@ -200,12 +200,12 @@static int __init ne2_probe1 (struct net_device *dev,int slot) { -int i, base_addr, irq; +int i, base_addr, irq, retval;unsigned char POS ;unsigned char SA_prom[32 ];const char *name ="NE/2" ;int start_page, stop_page; -static unsigned version_printed =0 ; +static unsigned version_printed;if (ei_debug && version_printed++ ==0 )printk (version);
@@ -226,6 +226,9 @@ base_addr = addresses[i -1 ]; irq = irqs[(POS &0x60 )>>5 ]; +if (!request_region (base_addr,NE_IO_EXTENT , dev->name)) +return -EBUSY ; +#ifdef DEBUG printk ("POS info : pos 2 = %#x ; base = %#x ; irq = %ld\n" ,POS , base_addr, irq);
@@ -239,7 +242,8 @@outb (0x21 , base_addr +NE_CMD );if (inb (base_addr +NE_CMD ) !=0x21 ) {printk ("NE/2 adapter not responding\n" ); -return -ENODEV ; + retval = -ENODEV ; + goto out; }/* In the crynwr sources they do a RAM-test here. I skip it. I suppose
@@ -260,7 +264,8 @@while ((inb_p (base_addr +EN0_ISR ) &ENISR_RESET ) ==0 )if (jiffies - reset_start_time >2 *HZ /100 ) {printk (" not found (no reset ack).\n" ); -return -ENODEV ; + retval = -ENODEV ; + goto out; }outb_p (0xff , base_addr +EN0_ISR );/* Ack all intr. */
@@ -309,14 +314,11 @@/* 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, -0 , name, dev); -if (irqval) { -printk (" unable to get IRQ %d (irqval=%d).\n" , - dev->irq, +irqval); -return -EAGAIN ; - } + retval =request_irq (dev->irq, ei_interrupt,0 , dev->name, dev); +if (retval) { +printk (" unable to get IRQ %d (irqval=%d).\n" , + dev->irq, retval); + goto out; } dev->base_addr = base_addr;
@@ -325,11 +327,10 @@if (ethdev_init (dev)) {printk (" unable to get memory for dev->priv.\n" );free_irq (dev->irq, dev); -return -ENOMEM ; + retval = -ENOMEM ; + goto out; } -request_region (base_addr,NE_IO_EXTENT , name); -for (i =0 ; i <ETHER_ADDR_LEN ; i++) {printk (" %2.2x" , SA_prom[i]); dev->dev_addr[i] = SA_prom[i];
@@ -362,6 +363,9 @@ dev->stop = &ne_close;NS8390_init (dev,0 );return 0 ; +out: +release_region (base_addr,NE_IO_EXTENT ); +return retval; }static int ne_open (struct net_device *dev)
linux/drivers/net/seeq8005.c renamed from mnt/disk/linux/drivers/net/seeq8005.c +26 -19
114 lines not on this page · raw message
linux/drivers/net/smc-mca.c renamed from mnt/disk/linux/drivers/net/smc-mca.c +8 -8
@@ -194,7 +194,7 @@ }if (!adapter_found) { -return ((base_addr || irq) ?ENXIO :ENODEV ); +return ((base_addr || irq) ? -ENXIO : -ENODEV ); }/* Adapter found. */
@@ -249,6 +249,9 @@if (dev->mem_start ==0 )/* sanity check, shouldn't happen */ return -ENODEV ; +if (!request_region (ioaddr,ULTRA_IO_EXTENT , dev->name)) +return -EBUSY ; + reg4 =inb (ioaddr +4 ) &0x7f ;outb (reg4, ioaddr +4 );
@@ -279,14 +282,10 @@if (ethdev_init (dev)) {printk (KERN_INFO ", no memory for dev->priv.\n" ); +release_region (ioaddr,ULTRA_IO_EXTENT );return -ENOMEM ; } -/* OK, we are certain this is going to work. Setup the device. -*/ - -request_region (ioaddr,ULTRA_IO_EXTENT ,"smc-mca" ); -/* The 8390 isn't at the base address, so fake the offset */
@@ -322,9 +321,10 @@static int ultramca_open (struct net_device *dev) {int ioaddr = dev->base_addr -ULTRA_NIC_OFFSET ;/* ASIC addr */ +int retval; -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;outb (ULTRA_MEMENB , ioaddr);/* Enable memory */ outb (0x80 , ioaddr +5 );/* ??? */
linux/drivers/net/smc-ultra.c renamed from mnt/disk/linux/drivers/net/smc-ultra.c +27 -20
104 lines not on this page · raw message
linux/drivers/net/smc-ultra32.c renamed from mnt/disk/linux/drivers/net/smc-ultra32.c +47 -28
136 lines not on this page · raw message
Quoted 11 lines · Andrey Panin
Hi all,
new net drivers patchset (against 2.4.0-test11-pre1) attached.
Modifications:
check_region()removal, passingdev->nametorequest_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
Signature · 7 lines
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/