patch-2.4.0-test11 linux/drivers/net/cs89x0.c
Next file: linux/drivers/net/de4x5.c
Previous file: linux/drivers/net/bmac.c
Back to the patch index
Back to the overall index
- Lines: 212
- Date:
Tue Nov 14 11:34:25 2000
- Orig file:
v2.4.0-test10/linux/drivers/net/cs89x0.c
- Orig date:
Tue Oct 31 12:42:26 2000
diff -u --recursive --new-file v2.4.0-test10/linux/drivers/net/cs89x0.c linux/drivers/net/cs89x0.c
@@ -66,10 +66,18 @@
: abstracted IRQ mapping to support CONFIG_ARCH_CLPS7500 arch
: (Jason Gunthorpe <jgg@ualberta.ca>)
+ Andrew Morton : Kernel 2.4.0-test11-pre4
+ : Use dev->name in request_*() (Andrey Panin)
+ : Fix an error-path memleak in init_module()
+ : Preserve return value from request_irq()
+ : Fix type of `media' module parm (Keith Owens)
+ : Use SET_MODULE_OWNER()
+ : Tidied up strange request_irq() abuse in net_open().
+
*/
-static char *version =
-"cs89x0.c: v2.3.99-pre1-2 Russell Nelson <nelson@crynwr.com>, Andrew Morton <andrewm@uow.edu.au>\n";
+static char version[] =
+"cs89x0.c: v2.4.0-test11-pre4 Russell Nelson <nelson@crynwr.com>, Andrew Morton <andrewm@uow.edu.au>\n";
/* ======================= end of configuration ======================= */
@@ -77,13 +85,8 @@
/* Always include 'config.h' first in case the user wants to turn on
or override something. */
#include <linux/config.h>
-#ifdef MODULE
#include <linux/module.h>
#include <linux/version.h>
-#else
-#define MOD_INC_USE_COUNT
-#define MOD_DEC_USE_COUNT
-#endif
/*
* Set this to zero to disable DMA code
@@ -97,7 +100,7 @@
* Set this to zero to remove all the debug statements via
* dead code elimination
*/
-#define DEBUGGING 0
+#define DEBUGGING 1
/*
Sources:
@@ -254,6 +257,8 @@
int i;
int base_addr = dev ? dev->base_addr : 0;
+ SET_MODULE_OWNER(dev);
+
if (net_debug)
printk("cs89x0:cs89x0_probe()\n");
@@ -378,8 +383,8 @@
lp = (struct net_local *)dev->priv;
/* Grab the region so we can find another board if autoIRQ fails. */
- if (!request_region(ioaddr, NETCARD_IO_EXTENT, "cs89x0")) {
- retval = -ENODEV;
+ if (!request_region(ioaddr, NETCARD_IO_EXTENT, dev->name)) {
+ retval = -EBUSY;
goto out1;
}
@@ -985,7 +990,7 @@
int i;
if (chip_type == CS8900) {
- /* Search the mapping table for the corrisponding IRQ pin. */
+ /* Search the mapping table for the corresponding IRQ pin. */
for (i = 0; i != sizeof(cs8900_irq_map)/sizeof(cs8900_irq_map[0]); i++)
if (cs8900_irq_map[i] == irq)
break;
@@ -1016,8 +1021,6 @@
int i;
int ret;
- MOD_INC_USE_COUNT;
-
if (dev->irq < 2) {
/* Allow interrupts to be generated by the chip */
/* Cirrus' release had this: */
@@ -1027,20 +1030,20 @@
/* And 2.3.47 had this: */
writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON);
- for (i = 2; i < CS8920_NO_INTS; i++) if ((1 << dev->irq) & lp->irq_map) {
- if (request_irq (i, NULL, 0, "cs89x0", dev) != -EBUSY) {
- write_irq(dev, lp->chip_type, i);
- writereg(dev, PP_BufCFG, GENERATE_SW_INTERRUPT);
- if (request_irq (dev->irq = i, &net_interrupt, 0, "cs89x0", dev) == 0)
+ for (i = 2; i < CS8920_NO_INTS; i++) {
+ if ((1 << dev->irq) & lp->irq_map) {
+ if (request_irq(i, net_interrupt, 0, dev->name, dev) == 0) {
+ dev->irq = i;
+ write_irq(dev, lp->chip_type, i);
+ /* writereg(dev, PP_BufCFG, GENERATE_SW_INTERRUPT); */
break;
+ }
}
}
-
if (i >= CS8920_NO_INTS) {
writereg(dev, PP_BusCTL, 0); /* disable interrupts. */
- if (net_debug)
- printk("cs89x0: can't get an interrupt\n");
+ printk(KERN_ERR "cs89x0: can't get an interrupt\n");
ret = -EAGAIN;
goto bad_out;
}
@@ -1058,10 +1061,10 @@
writereg(dev, PP_BusCTL, ENABLE_IRQ | MEMORY_ON);
#endif
write_irq(dev, lp->chip_type, dev->irq);
- if (request_irq(dev->irq, &net_interrupt, 0, "cs89x0", dev)) {
+ ret = request_irq(dev->irq, &net_interrupt, 0, dev->name, dev);
+ if (ret) {
if (net_debug)
- printk("cs89x0: request_irq(%d) failed\n", dev->irq);
- ret = -EAGAIN;
+ printk(KERN_DEBUG "cs89x0: request_irq(%d) failed\n", dev->irq);
goto bad_out;
}
}
@@ -1089,7 +1092,7 @@
goto release_irq;
}
memset(lp->dma_buff, 0, lp->dmasize * 1024); /* Why? */
- if (request_dma(dev->dma, "cs89x0")) {
+ if (request_dma(dev->dma, dev->name)) {
printk(KERN_ERR "%s: cannot get dma channel %d\n", dev->name, dev->dma);
goto release_irq;
}
@@ -1231,11 +1234,10 @@
#endif
);
netif_start_queue(dev);
- if (net_debug)
+ if (net_debug > 1)
printk("cs89x0: net_open() succeeded\n");
return 0;
bad_out:
- MOD_DEC_USE_COUNT;
return ret;
}
@@ -1482,7 +1484,6 @@
#endif
/* Update the statistics here. */
- MOD_DEC_USE_COUNT;
return 0;
}
@@ -1576,7 +1577,7 @@
MODULE_PARM(io, "i");
MODULE_PARM(irq, "i");
MODULE_PARM(debug, "i");
-MODULE_PARM(media, "s");
+MODULE_PARM(media, "c8");
MODULE_PARM(duplex, "i");
MODULE_PARM(dma , "i");
MODULE_PARM(dmasize , "i");
@@ -1616,6 +1617,7 @@
init_module(void)
{
struct net_local *lp;
+ int ret = 0;
#if DEBUGGING
net_debug = debug;
@@ -1661,21 +1663,27 @@
if (io == 0) {
printk(KERN_ERR "cs89x0.c: Module autoprobing not allowed.\n");
printk(KERN_ERR "cs89x0.c: Append io=0xNNN\n");
- return -EPERM;
+ ret = -EPERM;
+ goto out;
}
#if ALLOW_DMA
if (use_dma && dmasize != 16 && dmasize != 64) {
printk(KERN_ERR "cs89x0.c: dma size must be either 16K or 64K, not %dK\n", dmasize);
- return -EPERM;
+ ret = -EPERM;
+ goto out;
}
#endif
if (register_netdev(&dev_cs89x0) != 0) {
printk(KERN_ERR "cs89x0.c: No card found at 0x%x\n", io);
- return -ENXIO;
+ ret = -ENXIO;
+ goto out;
}
- return 0;
+out:
+ if (ret)
+ kfree(dev_cs89x0.priv);
+ return ret;
}
void
@@ -1695,7 +1703,6 @@
/*
* Local variables:
- * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/include -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DMODULE -DCONFIG_MODVERSIONS -c cs89x0.c"
* version-control: t
* kept-new-versions: 5
* c-indent-level: 8
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)