Commit 461d5019 authored by Stephen Hemminger's avatar Stephen Hemminger

[PATCH] (03/12) Probe2 -- ni65

Convert ni65 driver to new probing; patch sequence goes bottom
up on the probe list.

	* switched ni65 to dynamic allocation
	* ni65: fixed ->irq and ->dma clobbering on autoprobe
parent 2a550512
...@@ -70,7 +70,7 @@ extern int lne390_probe(struct net_device *); ...@@ -70,7 +70,7 @@ extern int lne390_probe(struct net_device *);
extern int e2100_probe(struct net_device *); extern int e2100_probe(struct net_device *);
extern int ni5010_probe(struct net_device *); extern int ni5010_probe(struct net_device *);
extern int ni52_probe(struct net_device *); extern int ni52_probe(struct net_device *);
extern int ni65_probe(struct net_device *); extern struct net_device *ni65_probe(int unit);
extern int sonic_probe(struct net_device *); extern int sonic_probe(struct net_device *);
extern int SK_init(struct net_device *); extern int SK_init(struct net_device *);
extern int seeq8005_probe(struct net_device *); extern int seeq8005_probe(struct net_device *);
...@@ -286,6 +286,10 @@ static struct devprobe isa_probes[] __initdata = { ...@@ -286,6 +286,10 @@ static struct devprobe isa_probes[] __initdata = {
#ifdef CONFIG_NI52 #ifdef CONFIG_NI52
{ni52_probe, 0}, {ni52_probe, 0},
#endif #endif
{NULL, 0},
};
static struct devprobe2 isa_probes2[] __initdata = {
#ifdef CONFIG_NI65 #ifdef CONFIG_NI65
{ni65_probe, 0}, {ni65_probe, 0},
#endif #endif
...@@ -399,6 +403,7 @@ static void __init ethif_probe2(int unit) ...@@ -399,6 +403,7 @@ static void __init ethif_probe2(int unit)
if (base_addr == 1) if (base_addr == 1)
return; return;
probe_list2(unit, isa_probes2, base_addr == 0) &&
probe_list2(unit, parport_probes, base_addr == 0); probe_list2(unit, parport_probes, base_addr == 0);
} }
......
...@@ -343,29 +343,64 @@ static int ni65_close(struct net_device *dev) ...@@ -343,29 +343,64 @@ static int ni65_close(struct net_device *dev)
return 0; return 0;
} }
static void cleanup_card(struct net_device *dev)
{
struct priv *p = (struct priv *) dev->priv;
disable_dma(dev->dma);
free_dma(dev->dma);
release_region(dev->base_addr, cards[p->cardno].total_size);
ni65_free_buffer(p);
}
/* set: io,irq,dma or set it when calling insmod */
static int irq;
static int io;
static int dma;
/* /*
* Probe The Card (not the lance-chip) * Probe The Card (not the lance-chip)
*/ */
#ifdef MODULE struct net_device * __init ni65_probe(int unit)
static
#endif
int __init ni65_probe(struct net_device *dev)
{ {
int *port; struct net_device *dev = alloc_etherdev(0);
static int ports[] = {0x360,0x300,0x320,0x340, 0}; static int ports[] = {0x360,0x300,0x320,0x340, 0};
int *port;
if (dev->base_addr > 0x1ff) /* Check a single specified location. */ int err = 0;
return ni65_probe1(dev, dev->base_addr);
else if (dev->base_addr > 0) /* Don't probe at all. */ if (!dev)
return -ENXIO; return ERR_PTR(-ENOMEM);
for (port = ports; *port; port++) if (unit >= 0) {
{ sprintf(dev->name, "eth%d", unit);
if (ni65_probe1(dev, *port) == 0) netdev_boot_setup_check(dev);
return 0; irq = dev->irq;
dma = dev->dma;
} else {
dev->base_addr = io;
} }
return -ENODEV; if (dev->base_addr > 0x1ff) { /* Check a single specified location. */
err = ni65_probe1(dev, dev->base_addr);
} else if (dev->base_addr > 0) { /* Don't probe at all. */
err = -ENXIO;
} else {
for (port = ports; *port && ni65_probe1(dev, *port); port++)
;
if (!*port)
err = -ENODEV;
}
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
cleanup_card(dev);
out:
free_netdev(dev);
return ERR_PTR(err);
} }
/* /*
...@@ -377,6 +412,9 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr) ...@@ -377,6 +412,9 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
struct priv *p; struct priv *p;
unsigned long flags; unsigned long flags;
dev->irq = irq;
dev->dma = dma;
for(i=0;i<NUM_CARDS;i++) { for(i=0;i<NUM_CARDS;i++) {
if(!request_region(ioaddr, cards[i].total_size, cards[i].cardname)) if(!request_region(ioaddr, cards[i].total_size, cards[i].cardname))
continue; continue;
...@@ -521,9 +559,6 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr) ...@@ -521,9 +559,6 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
dev->watchdog_timeo = HZ/2; dev->watchdog_timeo = HZ/2;
dev->get_stats = ni65_get_stats; dev->get_stats = ni65_get_stats;
dev->set_multicast_list = set_multicast_list; dev->set_multicast_list = set_multicast_list;
ether_setup(dev);
return 0; /* everything is OK */ return 0; /* everything is OK */
} }
...@@ -1213,12 +1248,7 @@ static void set_multicast_list(struct net_device *dev) ...@@ -1213,12 +1248,7 @@ static void set_multicast_list(struct net_device *dev)
} }
#ifdef MODULE #ifdef MODULE
static struct net_device dev_ni65 = { .base_addr = 0x360, .irq = 9, .init = ni65_probe }; static struct net_device *dev_ni65;
/* set: io,irq,dma or set it when calling insmod */
static int irq;
static int io;
static int dma;
MODULE_PARM(irq, "i"); MODULE_PARM(irq, "i");
MODULE_PARM(io, "i"); MODULE_PARM(io, "i");
...@@ -1229,26 +1259,15 @@ MODULE_PARM_DESC(dma, "ni6510 ISA DMA channel (ignored for some cards)"); ...@@ -1229,26 +1259,15 @@ MODULE_PARM_DESC(dma, "ni6510 ISA DMA channel (ignored for some cards)");
int init_module(void) int init_module(void)
{ {
dev_ni65.irq = irq; dev_ni65 = ni65_probe(-1);
dev_ni65.dma = dma; return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0;
dev_ni65.base_addr = io;
if (register_netdev(&dev_ni65) != 0)
return -EIO;
return 0;
} }
void cleanup_module(void) void cleanup_module(void)
{ {
struct priv *p; unregister_netdev(dev_ni65);
p = (struct priv *) dev_ni65.priv; cleanup_card(dev_ni65);
if(!p) free_netdev(dev_ni65);
BUG();
disable_dma(dev_ni65.dma);
free_dma(dev_ni65.dma);
unregister_netdev(&dev_ni65);
release_region(dev_ni65.base_addr,cards[p->cardno].total_size);
ni65_free_buffer(p);
dev_ni65.priv = NULL;
} }
#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