Commit ca652dfc authored by Stephen Hemminger's avatar Stephen Hemminger

[PATCH] (9/42) seeq8005

Based on viro NE33-seeq8005
	* switched seeq8005 to dynamic allocation
	* seeq8005: embedded ->priv
	* seeq8005: fixed resource leaks on failure exits
	* seeq8005: fixed clobbering on autoprobe
	* seeq8005: fixed jiffies truncation
	* seeq8005: fixed a typo in Kconfig - module is _not_ called ewrk3
parent 471a1ecf
...@@ -72,7 +72,7 @@ extern struct net_device *ni52_probe(int unit); ...@@ -72,7 +72,7 @@ extern struct net_device *ni52_probe(int unit);
extern struct net_device *ni65_probe(int unit); extern struct net_device *ni65_probe(int unit);
extern int sonic_probe(struct net_device *); extern int sonic_probe(struct net_device *);
extern struct net_device *SK_init(int unit); extern struct net_device *SK_init(int unit);
extern int seeq8005_probe(struct net_device *); extern struct net_device *seeq8005_probe(int unit);
extern int smc_init( struct net_device * ); extern int smc_init( struct net_device * );
extern int atarilance_probe(struct net_device *); extern int atarilance_probe(struct net_device *);
extern int sun3lance_probe(struct net_device *); extern int sun3lance_probe(struct net_device *);
...@@ -230,14 +230,14 @@ static struct devprobe isa_probes[] __initdata = { ...@@ -230,14 +230,14 @@ static struct devprobe isa_probes[] __initdata = {
#endif #endif
#ifdef CONFIG_SMC9194 #ifdef CONFIG_SMC9194
{smc_init, 0}, {smc_init, 0},
#endif
#ifdef CONFIG_SEEQ8005
{seeq8005_probe, 0},
#endif #endif
{NULL, 0}, {NULL, 0},
}; };
static struct devprobe2 isa_probes2[] __initdata = { static struct devprobe2 isa_probes2[] __initdata = {
#ifdef CONFIG_SEEQ8005
{seeq8005_probe, 0},
#endif
#ifdef CONFIG_CS89x0 #ifdef CONFIG_CS89x0
{cs89x0_probe, 0}, {cs89x0_probe, 0},
#endif #endif
......
...@@ -78,8 +78,6 @@ struct net_local { ...@@ -78,8 +78,6 @@ struct net_local {
/* Index to functions, as function prototypes. */ /* Index to functions, as function prototypes. */
extern int seeq8005_probe(struct net_device *dev);
static int seeq8005_probe1(struct net_device *dev, int ioaddr); static int seeq8005_probe1(struct net_device *dev, int ioaddr);
static int seeq8005_open(struct net_device *dev); static int seeq8005_open(struct net_device *dev);
static void seeq8005_timeout(struct net_device *dev); static void seeq8005_timeout(struct net_device *dev);
...@@ -102,22 +100,48 @@ static inline void wait_for_buffer(struct net_device *dev); ...@@ -102,22 +100,48 @@ static inline void wait_for_buffer(struct net_device *dev);
If dev->base_addr == 1, always return failure. If dev->base_addr == 1, always return failure.
*/ */
int __init static int io = 0x320;
seeq8005_probe(struct net_device *dev) static int irq = 10;
{
int i;
int base_addr = dev ? dev->base_addr : 0;
if (base_addr > 0x1ff) /* Check a single specified location. */
return seeq8005_probe1(dev, base_addr);
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
for (i = 0; seeq8005_portlist[i]; i++) struct net_device * __init seeq8005_probe(int unit)
if (seeq8005_probe1(dev, seeq8005_portlist[i]) == 0) {
return 0; struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
unsigned *port;
int err = 0;
if (!dev)
return ERR_PTR(-ENODEV);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
io = dev->base_addr;
irq = dev->irq;
}
return -ENODEV; if (io > 0x1ff) { /* Check a single specified location. */
err = seeq8005_probe1(dev, io);
} else if (io != 0) { /* Don't probe at all. */
err = -ENXIO;
} else {
for (port = seeq8005_portlist; *port; port++) {
if (seeq8005_probe1(dev, *port) == 0)
break;
}
if (!*port)
err = -ENODEV;
}
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
release_region(dev->base_addr, SEEQ8005_IO_EXTENT);
out:
free_netdev(dev);
return ERR_PTR(err);
} }
/* This is the real probe routine. Linux has a history of friendly device /* This is the real probe routine. Linux has a history of friendly device
...@@ -274,6 +298,7 @@ static int __init seeq8005_probe1(struct net_device *dev, int ioaddr) ...@@ -274,6 +298,7 @@ static int __init seeq8005_probe1(struct net_device *dev, int ioaddr)
/* Fill in the 'dev' fields. */ /* Fill in the 'dev' fields. */
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
dev->irq = irq;
/* Retrieve and print the ethernet address. */ /* Retrieve and print the ethernet address. */
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
...@@ -307,13 +332,6 @@ static int __init seeq8005_probe1(struct net_device *dev, int ioaddr) ...@@ -307,13 +332,6 @@ static int __init seeq8005_probe1(struct net_device *dev, int ioaddr)
} }
} }
#endif #endif
/* Initialize the device structure. */
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev->priv == NULL)
return -ENOMEM;
memset(dev->priv, 0, sizeof(struct net_local));
dev->open = seeq8005_open; dev->open = seeq8005_open;
dev->stop = seeq8005_close; dev->stop = seeq8005_close;
dev->hard_start_xmit = seeq8005_send_packet; dev->hard_start_xmit = seeq8005_send_packet;
...@@ -321,10 +339,6 @@ static int __init seeq8005_probe1(struct net_device *dev, int ioaddr) ...@@ -321,10 +339,6 @@ static int __init seeq8005_probe1(struct net_device *dev, int ioaddr)
dev->watchdog_timeo = HZ/20; dev->watchdog_timeo = HZ/20;
dev->get_stats = seeq8005_get_stats; dev->get_stats = seeq8005_get_stats;
dev->set_multicast_list = set_multicast_list; dev->set_multicast_list = set_multicast_list;
/* Fill in the fields of the device structure with ethernet values. */
ether_setup(dev);
dev->flags &= ~IFF_MULTICAST; dev->flags &= ~IFF_MULTICAST;
return 0; return 0;
...@@ -721,9 +735,7 @@ inline void wait_for_buffer(struct net_device * dev) ...@@ -721,9 +735,7 @@ inline void wait_for_buffer(struct net_device * dev)
#ifdef MODULE #ifdef MODULE
static struct net_device dev_seeq = { .init = seeq8005_probe }; static struct net_device *dev_seeq;
static int io = 0x320;
static int irq = 10;
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_PARM(io, "i"); MODULE_PARM(io, "i");
MODULE_PARM(irq, "i"); MODULE_PARM(irq, "i");
...@@ -732,28 +744,17 @@ MODULE_PARM_DESC(irq, "SEEQ 8005 IRQ number"); ...@@ -732,28 +744,17 @@ MODULE_PARM_DESC(irq, "SEEQ 8005 IRQ number");
int init_module(void) int init_module(void)
{ {
dev_seeq.irq=irq; dev_seeq = seeq8005_probe(-1);
dev_seeq.base_addr=io; if (IS_ERR(dev_seeq))
if (register_netdev(&dev_seeq) != 0) return PTR_ERR(dev_seeq);
return -EIO;
return 0; return 0;
} }
void cleanup_module(void) void cleanup_module(void)
{ {
unregister_netdev(&dev_seeq); unregister_netdev(dev_seeq);
release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT);
/* free_netdev(dev_seeq);
* Free up the private structure, or leak memory :-)
*/
kfree(dev_seeq.priv);
dev_seeq.priv = NULL; /* gets re-allocated by el1_probe1 */
/*
* If we don't do this, we can't re-insmod it later.
*/
release_region(dev_seeq.base_addr, SEEQ8005_IO_EXTENT);
} }
#endif /* MODULE */ #endif /* MODULE */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment