Commit 9c7f8a73 authored by Jeff Garzik's avatar Jeff Garzik

Manually merge drivers/net/3c527.c changes.

parents 72f64a05 a1b7d53c
......@@ -60,7 +60,6 @@ static const char version[] =
#include "3c503.h"
#define WRD_COUNT 4
int el2_probe(struct net_device *dev);
static int el2_pio_probe(struct net_device *dev);
static int el2_probe1(struct net_device *dev, int ioaddr);
......@@ -90,11 +89,11 @@ static struct ethtool_ops netdev_ethtool_ops;
If the ethercard isn't found there is an optional probe for
ethercard jumpered to programmed-I/O mode.
*/
int __init
el2_probe(struct net_device *dev)
static int __init do_el2_probe(struct net_device *dev)
{
int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
int base_addr = dev->base_addr;
int irq = dev->irq;
SET_MODULE_OWNER(dev);
......@@ -104,16 +103,13 @@ el2_probe(struct net_device *dev)
return -ENXIO;
for (addr = addrs; *addr; addr++) {
int i;
unsigned int base_bits = isa_readb(*addr);
/* Find first set bit. */
for(i = 7; i >= 0; i--, base_bits >>= 1)
if (base_bits & 0x1)
break;
if (base_bits != 1)
unsigned base_bits = isa_readb(*addr);
int i = ffs(base_bits) - 1;
if (i == -1 || base_bits != (1 << i))
continue;
if (el2_probe1(dev, netcard_portlist[i]) == 0)
return 0;
dev->irq = irq;
}
#if ! defined(no_probe_nonshared_memory)
return el2_pio_probe(dev);
......@@ -128,20 +124,57 @@ static int __init
el2_pio_probe(struct net_device *dev)
{
int i;
int base_addr = dev ? dev->base_addr : 0;
int base_addr = dev->base_addr;
int irq = dev->irq;
if (base_addr > 0x1ff) /* Check a single specified location. */
return el2_probe1(dev, base_addr);
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
for (i = 0; netcard_portlist[i]; i++)
for (i = 0; netcard_portlist[i]; i++) {
if (el2_probe1(dev, netcard_portlist[i]) == 0)
return 0;
dev->irq = irq;
}
return -ENODEV;
}
static void cleanup_card(struct net_device *dev)
{
/* NB: el2_close() handles free_irq */
release_region(dev->base_addr, EL2_IO_EXTENT);
kfree(dev->priv);
}
struct net_device * __init el2_probe(int unit)
{
struct net_device *dev = alloc_etherdev(0);
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_el2_probe(dev);
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);
}
/* Probe for the Etherlink II card at I/O port base IOADDR,
returning non-zero on success. If found, set the station
address and memory parameters in DEVICE. */
......@@ -152,15 +185,19 @@ el2_probe1(struct net_device *dev, int ioaddr)
static unsigned version_printed;
unsigned long vendor_id;
/* FIXME: code reads ioaddr + 0x400, we request ioaddr + 16 */
if (!request_region(ioaddr, EL2_IO_EXTENT, dev->name))
return -EBUSY;
if (!request_region(ioaddr + 0x400, 8, dev->name)) {
retval = -EBUSY;
goto out;
}
/* Reset and/or avoid any lurking NE2000 */
if (inb(ioaddr + 0x408) == 0xff) {
mdelay(1);
retval = -ENODEV;
goto out;
goto out1;
}
/* We verify that it's a 3C503 board by checking the first three octets
......@@ -171,7 +208,7 @@ el2_probe1(struct net_device *dev, int ioaddr)
if ( (iobase_reg & (iobase_reg - 1))
|| (membase_reg & (membase_reg - 1))) {
retval = -ENODEV;
goto out;
goto out1;
}
saved_406 = inb_p(ioaddr + 0x406);
outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
......@@ -184,7 +221,7 @@ el2_probe1(struct net_device *dev, int ioaddr)
/* Restore the register we frobbed. */
outb(saved_406, ioaddr + 0x406);
retval = -ENODEV;
goto out;
goto out1;
}
if (ei_debug && version_printed++ == 0)
......@@ -195,7 +232,7 @@ el2_probe1(struct net_device *dev, int ioaddr)
if (ethdev_init(dev)) {
printk ("3c503: unable to allocate memory for dev->priv.\n");
retval = -ENOMEM;
goto out;
goto out1;
}
printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
......@@ -322,7 +359,10 @@ el2_probe1(struct net_device *dev, int ioaddr)
printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
dev->name, ei_status.name, (wordlength+1)<<3);
}
release_region(ioaddr + 0x400, 8);
return 0;
out1:
release_region(ioaddr + 0x400, 8);
out:
release_region(ioaddr, EL2_IO_EXTENT);
return retval;
......@@ -633,7 +673,7 @@ static struct ethtool_ops netdev_ethtool_ops = {
#ifdef MODULE
#define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */
static struct net_device dev_el2[MAX_EL2_CARDS];
static struct net_device *dev_el2[MAX_EL2_CARDS];
static int io[MAX_EL2_CARDS];
static int irq[MAX_EL2_CARDS];
static int xcvr[MAX_EL2_CARDS]; /* choose int. or ext. xcvr */
......@@ -651,28 +691,35 @@ ISA device autoprobes on a running machine are not recommended. */
int
init_module(void)
{
struct net_device *dev;
int this_dev, found = 0;
for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
struct net_device *dev = &dev_el2[this_dev];
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
dev->init = el2_probe;
if (io[this_dev] == 0) {
if (this_dev != 0) break; /* only autoprobe 1st one */
printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n");
}
if (register_netdev(dev) != 0) {
printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
if (found != 0) { /* Got at least one. */
return 0;
dev = alloc_etherdev(0);
if (!dev)
break;
dev->priv = NULL;
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
if (do_el2_probe(dev) == 0) {
if (register_netdev(dev) == 0) {
dev_el2[found++] = dev;
continue;
}
return -ENXIO;
cleanup_card(dev);
}
found++;
free_netdev(dev);
printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
break;
}
return 0;
if (found)
return 0;
return -ENXIO;
}
void
......@@ -681,13 +728,11 @@ cleanup_module(void)
int this_dev;
for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
struct net_device *dev = &dev_el2[this_dev];
if (dev->priv != NULL) {
void *priv = dev->priv;
/* NB: el2_close() handles free_irq */
release_region(dev->base_addr, EL2_IO_EXTENT);
struct net_device *dev = dev_el2[this_dev];
if (dev) {
unregister_netdev(dev);
kfree(priv);
cleanup_card(dev);
free_netdev(dev);
}
}
}
......
This diff is collapsed.
......@@ -410,7 +410,7 @@ static int elmc_getinfo(char *buf, int slot, void *d)
/*****************************************************************/
int __init elmc_probe(struct net_device *dev)
static int __init do_elmc_probe(struct net_device *dev)
{
static int slot;
int base_addr = dev->base_addr;
......@@ -420,7 +420,7 @@ int __init elmc_probe(struct net_device *dev)
int i = 0;
unsigned int size = 0;
int retval;
struct priv *pr;
struct priv *pr = dev->priv;
SET_MODULE_OWNER(dev);
if (MCA_bus == 0) {
......@@ -455,10 +455,9 @@ int __init elmc_probe(struct net_device *dev)
}
/* we didn't find any 3c523 in the slots we checked for */
if (slot == MCA_NOTFOUND) {
retval = ((base_addr || irq) ? -ENXIO : -ENODEV);
goto err_out;
}
if (slot == MCA_NOTFOUND)
return ((base_addr || irq) ? -ENXIO : -ENODEV);
mca_set_adapter_name(slot, "3Com 3c523 Etherlink/MC");
mca_set_adapter_procfn(slot, (MCA_ProcFn) elmc_getinfo, dev);
......@@ -497,13 +496,7 @@ int __init elmc_probe(struct net_device *dev)
break;
}
pr = dev->priv = kmalloc(sizeof(struct priv), GFP_KERNEL);
if (dev->priv == NULL) {
retval = -ENOMEM;
goto err_out;
}
memset(pr, 0, sizeof(struct priv));
pr->slot = slot;
printk(KERN_INFO "%s: 3Com 3c523 Rev 0x%x at %#lx\n", dev->name, (int) revision,
......@@ -530,8 +523,6 @@ int __init elmc_probe(struct net_device *dev)
if (!check586(dev, dev->mem_start, size)) {
printk(KERN_ERR "%s: memprobe, Can't find memory at 0x%lx!\n", dev->name,
dev->mem_start);
kfree(dev->priv);
dev->priv = NULL;
retval = -ENODEV;
goto err_out;
}
......@@ -573,8 +564,6 @@ int __init elmc_probe(struct net_device *dev)
#endif
dev->ethtool_ops = &netdev_ethtool_ops;
ether_setup(dev);
/* note that we haven't actually requested the IRQ from the kernel.
That gets done in elmc_open(). I'm not sure that's such a good idea,
but it works, so I'll go with it. */
......@@ -585,9 +574,41 @@ int __init elmc_probe(struct net_device *dev)
return 0;
err_out:
mca_set_adapter_procfn(slot, NULL, NULL);
release_region(dev->base_addr, ELMC_IO_EXTENT);
return retval;
}
static void cleanup_card(struct net_device *dev)
{
mca_set_adapter_procfn(((struct priv *) (dev->priv))->slot, NULL, NULL);
release_region(dev->base_addr, ELMC_IO_EXTENT);
}
struct net_device * __init elmc_probe(int unit)
{
struct net_device *dev = alloc_etherdev(sizeof(struct priv));
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
err = do_elmc_probe(dev);
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);
}
/**********************************************
* init the chip (elmc-interrupt should be disabled?!)
......@@ -1245,7 +1266,7 @@ static struct ethtool_ops netdev_ethtool_ops = {
/* Increase if needed ;) */
#define MAX_3C523_CARDS 4
static struct net_device dev_elmc[MAX_3C523_CARDS];
static struct net_device *dev_elmc[MAX_3C523_CARDS];
static int irq[MAX_3C523_CARDS];
static int io[MAX_3C523_CARDS];
MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_3C523_CARDS) "i");
......@@ -1258,16 +1279,24 @@ int init_module(void)
int this_dev,found = 0;
/* Loop until we either can't find any more cards, or we have MAX_3C523_CARDS */
for(this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++)
{
struct net_device *dev = &dev_elmc[this_dev];
for(this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {
struct net_device *dev = alloc_etherdev(sizeof(struct priv));
if (!dev)
break;
dev->irq=irq[this_dev];
dev->base_addr=io[this_dev];
dev->init=elmc_probe;
if(register_netdev(dev)!=0) {
if(io[this_dev]==0) break;
printk(KERN_WARNING "3c523.c: No 3c523 card found at io=%#x\n",io[this_dev]);
} else found++;
if (do_elmc_probe(dev) == 0) {
if (register_netdev(dev) == 0) {
dev_elmc[this_dev] = dev;
found++;
continue;
}
cleanup_card(dev);
}
free_netdev(dev);
if (io[this_dev]==0)
break;
printk(KERN_WARNING "3c523.c: No 3c523 card found at io=%#x\n",io[this_dev]);
}
if(found==0) {
......@@ -1279,31 +1308,12 @@ int init_module(void)
void cleanup_module(void)
{
int this_dev;
for(this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {
struct net_device *dev = &dev_elmc[this_dev];
if(dev->priv) {
/* shutdown interrupts on the card */
elmc_id_reset586();
if (dev->irq != 0) {
/* this should be done by close, but if we failed to
initialize properly something may have gotten hosed. */
free_irq(dev->irq, dev);
dev->irq = 0;
}
if (dev->base_addr != 0) {
release_region(dev->base_addr, ELMC_IO_EXTENT);
dev->base_addr = 0;
}
irq[this_dev] = 0;
io[this_dev] = 0;
for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {
struct net_device *dev = dev_elmc[this_dev];
if (dev) {
unregister_netdev(dev);
mca_set_adapter_procfn(((struct priv *) (dev->priv))->slot,
NULL, NULL);
kfree(dev->priv);
dev->priv = NULL;
cleanup_card(dev);
free_netdev(dev);
}
}
}
......
......@@ -212,8 +212,6 @@ static inline u16 next_tx(u16 tx) { return (tx+1)&(TX_RING_LEN-1); };
/* Index to functions, as function prototypes. */
extern int mc32_probe(struct net_device *dev);
static int mc32_probe1(struct net_device *dev, int ioaddr);
static int mc32_command(struct net_device *dev, u16 cmd, void *data, int len);
static int mc32_open(struct net_device *dev);
......@@ -226,9 +224,19 @@ static void mc32_set_multicast_list(struct net_device *dev);
static void mc32_reset_multicast_list(struct net_device *dev);
static struct ethtool_ops netdev_ethtool_ops;
static void cleanup_card(struct net_device *dev)
{
struct mc32_local *lp=dev->priv;
unsigned slot = lp->slot;
mca_mark_as_unused(slot);
mca_set_adapter_name(slot, NULL);
free_irq(dev->irq, dev);
release_region(dev->base_addr, MC32_IO_EXTENT);
}
/**
* mc32_probe - Search for supported boards
* @dev: device to probe
* @unit: interface number to use
*
* Because MCA bus is a real bus and we can scan for cards we could do a
* single scan for all boards here. Right now we use the passed in device
......@@ -236,10 +244,18 @@ static struct ethtool_ops netdev_ethtool_ops;
* in particular.
*/
int __init mc32_probe(struct net_device *dev)
struct net_device *__init mc32_probe(int unit)
{
struct net_device *dev = alloc_etherdev(sizeof(struct mc32_local));
static int current_mca_slot = -1;
int i;
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0)
sprintf(dev->name, "eth%d", unit);
SET_MODULE_OWNER(dev);
......@@ -260,12 +276,18 @@ int __init mc32_probe(struct net_device *dev)
mca_set_adapter_name(current_mca_slot,
mc32_adapters[i].name);
mca_mark_as_used(current_mca_slot);
return 0;
err = register_netdev(dev);
if (err) {
cleanup_card(dev);
free_netdev(dev);
dev = ERR_PTR(err);
}
return dev;
}
}
}
return -ENODEV;
return ERR_PTR(-ENODEV);
}
/**
......@@ -285,7 +307,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
int i, err;
u8 POS;
u32 base;
struct mc32_local *lp;
struct mc32_local *lp = dev->priv;
static u16 mca_io_bases[]={
0x7280,0x7290,
0x7680,0x7690,
......@@ -412,24 +434,14 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
* Grab the IRQ
*/
i = request_irq(dev->irq, &mc32_interrupt, SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
if (i) {
err = request_irq(dev->irq, &mc32_interrupt, SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
if (err) {
release_region(dev->base_addr, MC32_IO_EXTENT);
printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, dev->irq);
return i;
goto err_exit_ports;
}
/* Initialize the device structure. */
dev->priv = kmalloc(sizeof(struct mc32_local), GFP_KERNEL);
if (dev->priv == NULL)
{
err = -ENOMEM;
goto err_exit_irq;
}
memset(dev->priv, 0, sizeof(struct mc32_local));
lp = dev->priv;
memset(lp, 0, sizeof(struct mc32_local));
lp->slot = slot;
i=0;
......@@ -443,7 +455,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
{
printk(KERN_ERR "%s: failed to boot adapter.\n", dev->name);
err = -ENODEV;
goto err_exit_free;
goto err_exit_irq;
}
udelay(1000);
if(inb(dev->base_addr+2)&(1<<5))
......@@ -458,7 +470,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
else
printk(KERN_ERR "%s: unknown failure %d.\n", dev->name, base);
err = -ENODEV;
goto err_exit_free;
goto err_exit_irq;
}
base=0;
......@@ -474,7 +486,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
{
printk(KERN_ERR "%s: mailbox read fail (%d).\n", dev->name, i);
err = -ENODEV;
goto err_exit_free;
goto err_exit_irq;
}
}
......@@ -517,15 +529,11 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
dev->watchdog_timeo = HZ*5; /* Board does all the work */
dev->ethtool_ops = &netdev_ethtool_ops;
/* Fill in the fields of the device structure with ethernet values. */
ether_setup(dev);
return 0;
err_exit_free:
kfree(dev->priv);
err_exit_irq:
free_irq(dev->irq, dev);
err_exit_ports:
release_region(dev->base_addr, MC32_IO_EXTENT);
return err;
}
......@@ -1630,7 +1638,7 @@ static struct ethtool_ops netdev_ethtool_ops = {
#ifdef MODULE
static struct net_device this_device;
static struct net_device *this_device;
/**
* init_module - entry point
......@@ -1642,12 +1650,9 @@ static struct net_device this_device;
int init_module(void)
{
int result;
this_device.init = mc32_probe;
if ((result = register_netdev(&this_device)) != 0)
return result;
this_device = mc32_probe(-1);
if (IS_ERR(this_device))
return PTR_ERR(this_device);
return 0;
}
......@@ -1664,24 +1669,9 @@ int init_module(void)
void cleanup_module(void)
{
int slot;
unregister_netdev(&this_device);
/*
* If we don't do this, we can't re-insmod it later.
*/
if (this_device.priv)
{
struct mc32_local *lp=this_device.priv;
slot = lp->slot;
mca_mark_as_unused(slot);
mca_set_adapter_name(slot, NULL);
kfree(this_device.priv);
}
free_irq(this_device.irq, &this_device);
release_region(this_device.base_addr, MC32_IO_EXTENT);
unregister_netdev(this_device);
cleanup_card(this_device);
free_netdev(this_device);
}
#endif /* MODULE */
......@@ -112,7 +112,6 @@ endif
obj-$(CONFIG_DUMMY) += dummy.o
obj-$(CONFIG_DE600) += de600.o
obj-$(CONFIG_DE620) += de620.o
obj-$(CONFIG_AT1500) += lance.o
obj-$(CONFIG_LANCE) += lance.o
obj-$(CONFIG_SUN3_82586) += sun3_82586.o
obj-$(CONFIG_SUN3LANCE) += sun3lance.o
......
......@@ -40,58 +40,57 @@
ethernet adaptor have the name "eth[0123...]".
*/
extern int ne2_probe(struct net_device *dev);
extern int hp100_probe(struct net_device *dev);
extern int ultra_probe(struct net_device *dev);
extern int ultra32_probe(struct net_device *dev);
extern int wd_probe(struct net_device *dev);
extern int el2_probe(struct net_device *dev);
extern int ne_probe(struct net_device *dev);
extern int hp_probe(struct net_device *dev);
extern int hp_plus_probe(struct net_device *dev);
extern int express_probe(struct net_device *);
extern int eepro_probe(struct net_device *);
extern int at1500_probe(struct net_device *);
extern int at1700_probe(struct net_device *);
extern int fmv18x_probe(struct net_device *);
extern int eth16i_probe(struct net_device *);
extern struct net_device *ne2_probe(int unit);
extern struct net_device *hp100_probe(int unit);
extern struct net_device *ultra_probe(int unit);
extern struct net_device *ultra32_probe(int unit);
extern struct net_device *wd_probe(int unit);
extern struct net_device *el2_probe(int unit);
extern struct net_device *ne_probe(int unit);
extern struct net_device *hp_probe(int unit);
extern struct net_device *hp_plus_probe(int unit);
extern struct net_device *express_probe(int unit);
extern struct net_device *eepro_probe(int unit);
extern struct net_device *at1700_probe(int unit);
extern struct net_device *fmv18x_probe(int unit);
extern struct net_device *eth16i_probe(int unit);
extern struct net_device *i82596_probe(int unit);
extern int ewrk3_probe(struct net_device *);
extern struct net_device *ewrk3_probe(int unit);
extern struct net_device *el1_probe(int unit);
extern struct net_device *wavelan_probe(int unit);
extern struct net_device *arlan_probe(int unit);
extern struct net_device *el16_probe(int unit);
extern int elmc_probe(struct net_device *);
extern int skmca_probe(struct net_device *);
extern struct net_device *elmc_probe(int unit);
extern struct net_device *skmca_probe(int unit);
extern struct net_device *elplus_probe(int unit);
extern int ac3200_probe(struct net_device *);
extern int es_probe(struct net_device *);
extern int lne390_probe(struct net_device *);
extern int e2100_probe(struct net_device *);
extern struct net_device *ac3200_probe(int unit);
extern struct net_device *es_probe(int unit);
extern struct net_device *lne390_probe(int unit);
extern struct net_device *e2100_probe(int unit);
extern struct net_device *ni5010_probe(int unit);
extern struct net_device *ni52_probe(int unit);
extern struct net_device *ni65_probe(int unit);
extern int sonic_probe(struct net_device *);
extern struct net_device *sonic_probe(int unit);
extern struct net_device *SK_init(int unit);
extern int seeq8005_probe(struct net_device *);
extern int smc_init( struct net_device * );
extern int atarilance_probe(struct net_device *);
extern int sun3lance_probe(struct net_device *);
extern int sun3_82586_probe(struct net_device *);
extern int apne_probe(struct net_device *);
extern int bionet_probe(struct net_device *);
extern int pamsnet_probe(struct net_device *);
extern int cs89x0_probe(struct net_device *dev);
extern int hplance_probe(struct net_device *dev);
extern int bagetlance_probe(struct net_device *);
extern int mvme147lance_probe(struct net_device *dev);
extern int tc515_probe(struct net_device *dev);
extern int lance_probe(struct net_device *dev);
extern int mace_probe(struct net_device *dev);
extern int macsonic_probe(struct net_device *dev);
extern int mac8390_probe(struct net_device *dev);
extern int mac89x0_probe(struct net_device *dev);
extern int mc32_probe(struct net_device *dev);
extern struct net_device *seeq8005_probe(int unit);
extern struct net_device *smc_init(int unit);
extern struct net_device *atarilance_probe(struct net_device *);
extern struct net_device *sun3lance_probe(int unit);
extern struct net_device *sun3_82586_probe(int unit);
extern struct net_device *apne_probe(int unit);
extern struct net_device *bionet_probe(int unit);
extern struct net_device *pamsnet_probe(int unit);
extern struct net_device *cs89x0_probe(int unit);
extern struct net_device *hplance_probe(int unit);
extern struct net_device *bagetlance_probe(int unit);
extern struct net_device *mvme147lance_probe(int unit);
extern struct net_device *tc515_probe(int unit);
extern struct net_device *lance_probe(int unit);
extern struct net_device *mace_probe(struct net_device *dev);
extern struct net_device *macsonic_probe(int unit);
extern struct net_device *mac8390_probe(int unit);
extern struct net_device *mac89x0_probe(int unit);
extern struct net_device *mc32_probe(int unit);
extern struct net_device *cops_probe(int unit);
extern struct net_device *ltpc_probe(void);
......@@ -104,42 +103,11 @@ extern int iph5526_probe(struct net_device *dev);
/* SBNI adapters */
extern int sbni_probe(int unit);
struct devprobe
{
int (*probe)(struct net_device *dev);
int status; /* non-zero if autoprobe has failed */
};
struct devprobe2 {
struct net_device *(*probe)(int unit);
int status; /* non-zero if autoprobe has failed */
};
/*
* probe_list walks a list of probe functions and calls each so long
* as a non-zero ioaddr is given, or as long as it hasn't already failed
* to find a card in the past (as recorded by "status") when asked to
* autoprobe (i.e. a probe that fails to find a card when autoprobing
* will not be asked to autoprobe again). It exits when a card is found.
*/
static int __init probe_list(struct net_device *dev, struct devprobe *plist)
{
struct devprobe *p = plist;
unsigned long base_addr = dev->base_addr;
while (p->probe != NULL) {
if (base_addr && p->probe(dev) == 0) /* probe given addr */
return 0;
else if (p->status == 0) { /* has autoprobe failed yet? */
p->status = p->probe(dev); /* no, try autoprobe */
if (p->status == 0)
return 0;
}
p++;
}
return -ENODEV;
}
static int __init probe_list2(int unit, struct devprobe2 *p, int autoprobe)
{
struct net_device *dev;
......@@ -161,7 +129,8 @@ static int __init probe_list2(int unit, struct devprobe2 *p, int autoprobe)
* drivers that probe for EISA cards (in the ISA group). These are the
* legacy EISA only driver probes, and also the legacy PCI probes
*/
static struct devprobe eisa_probes[] __initdata = {
static struct devprobe2 eisa_probes[] __initdata = {
#ifdef CONFIG_ULTRA32
{ultra32_probe, 0},
#endif
......@@ -177,8 +146,7 @@ static struct devprobe eisa_probes[] __initdata = {
{NULL, 0},
};
static struct devprobe mca_probes[] __initdata = {
static struct devprobe2 mca_probes[] __initdata = {
#ifdef CONFIG_NE2_MCA
{ne2_probe, 0},
#endif
......@@ -198,7 +166,7 @@ static struct devprobe mca_probes[] __initdata = {
* ISA probes that touch addresses < 0x400 (including those that also
* look for EISA/PCI/MCA cards in addition to ISA cards).
*/
static struct devprobe isa_probes[] __initdata = {
static struct devprobe2 isa_probes[] __initdata = {
#ifdef CONFIG_HP100 /* ISA, EISA & PCI */
{hp100_probe, 0},
#endif
......@@ -235,9 +203,6 @@ static struct devprobe isa_probes[] __initdata = {
#ifdef CONFIG_SEEQ8005
{seeq8005_probe, 0},
#endif
#ifdef CONFIG_AT1500
{at1500_probe, 0},
#endif
#ifdef CONFIG_CS89x0
{cs89x0_probe, 0},
#endif
......@@ -259,10 +224,6 @@ static struct devprobe isa_probes[] __initdata = {
#ifdef CONFIG_EWRK3 /* DEC EtherWORKS 3 */
{ewrk3_probe, 0},
#endif
{NULL, 0},
};
static struct devprobe2 isa_probes2[] __initdata = {
#if defined(CONFIG_APRICOT) || defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET) /* Intel I82596 */
{i82596_probe, 0},
#endif
......@@ -303,7 +264,7 @@ static struct devprobe2 parport_probes[] __initdata = {
{NULL, 0},
};
static struct devprobe m68k_probes[] __initdata = {
static struct devprobe2 m68k_probes[] __initdata = {
#ifdef CONFIG_ATARILANCE /* Lance-based Atari ethernet boards */
{atarilance_probe, 0},
#endif
......@@ -343,7 +304,7 @@ static struct devprobe m68k_probes[] __initdata = {
{NULL, 0},
};
static struct devprobe mips_probes[] __initdata = {
static struct devprobe2 mips_probes[] __initdata = {
#ifdef CONFIG_MIPS_JAZZ_SONIC
{sonic_probe, 0},
#endif
......@@ -358,44 +319,6 @@ static struct devprobe mips_probes[] __initdata = {
* per bus interface. This drives the legacy devices only for now.
*/
static int __init ethif_probe(int unit)
{
struct net_device *dev;
int err = -ENODEV;
dev = alloc_etherdev(0);
if (!dev)
return -ENOMEM;
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
/*
* Backwards compatibility - historically an I/O base of 1 was
* used to indicate not to probe for this ethN interface
*/
if (__dev_get_by_name(dev->name) || dev->base_addr == 1) {
free_netdev(dev);
return -ENXIO;
}
/*
* The arch specific probes are 1st so that any on-board ethernet
* will be probed before other ISA/EISA/MCA/PCI bus cards.
*/
if (probe_list(dev, m68k_probes) == 0 ||
probe_list(dev, mips_probes) == 0 ||
probe_list(dev, eisa_probes) == 0 ||
probe_list(dev, mca_probes) == 0 ||
probe_list(dev, isa_probes) == 0)
err = register_netdev(dev);
if (err)
free_netdev(dev);
return err;
}
static void __init ethif_probe2(int unit)
{
unsigned long base_addr = netdev_boot_base("eth", unit);
......@@ -403,7 +326,11 @@ static void __init ethif_probe2(int unit)
if (base_addr == 1)
return;
probe_list2(unit, isa_probes2, base_addr == 0) &&
probe_list2(unit, m68k_probes, base_addr == 0) &&
probe_list2(unit, mips_probes, base_addr == 0) &&
probe_list2(unit, eisa_probes, base_addr == 0) &&
probe_list2(unit, mca_probes, base_addr == 0) &&
probe_list2(unit, isa_probes, base_addr == 0) &&
probe_list2(unit, parport_probes, base_addr == 0);
}
......@@ -488,8 +415,7 @@ static int __init net_olddevs_init(void)
trif_probe2(num);
#endif
for (num = 0; num < 8; ++num)
if (!ethif_probe(num))
ethif_probe2(num);
ethif_probe2(num);
#ifdef CONFIG_COPS
cops_probe(0);
......
......@@ -75,7 +75,6 @@ static const char *port_name[4] = { "10baseT", "invalid", "AUI", "10base2"};
#define AC_START_PG 0x00 /* First page of 8390 TX buffer */
#define AC_STOP_PG 0x80 /* Last page +1 of the 8390 RX ring */
int ac3200_probe(struct net_device *dev);
static int ac_probe1(int ioaddr, struct net_device *dev);
static int ac_open(struct net_device *dev);
......@@ -96,9 +95,11 @@ static int ac_close_card(struct net_device *dev);
or the unique value in the station address PROM.
*/
int __init ac3200_probe(struct net_device *dev)
static int __init do_ac3200_probe(struct net_device *dev)
{
unsigned short ioaddr = dev->base_addr;
int irq = dev->irq;
int mem_start = dev->mem_start;
SET_MODULE_OWNER(dev);
......@@ -110,13 +111,53 @@ int __init ac3200_probe(struct net_device *dev)
if ( ! EISA_bus)
return -ENXIO;
for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000)
for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
if (ac_probe1(ioaddr, dev) == 0)
return 0;
dev->irq = irq;
dev->mem_start = mem_start;
}
return -ENODEV;
}
static void cleanup_card(struct net_device *dev)
{
/* Someday free_irq may be in ac_close_card() */
free_irq(dev->irq, dev);
release_region(dev->base_addr, AC_IO_EXTENT);
if (ei_status.reg0)
iounmap((void *)dev->mem_start);
kfree(dev->priv);
}
struct net_device * __init ac3200_probe(int unit)
{
struct net_device *dev = alloc_etherdev(0);
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_ac3200_probe(dev);
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);
}
static int __init ac_probe1(int ioaddr, struct net_device *dev)
{
int i, retval;
......@@ -338,7 +379,7 @@ static int ac_close_card(struct net_device *dev)
#ifdef MODULE
#define MAX_AC32_CARDS 4 /* Max number of AC32 cards per module */
static struct net_device dev_ac32[MAX_AC32_CARDS];
static struct net_device *dev_ac32[MAX_AC32_CARDS];
static int io[MAX_AC32_CARDS];
static int irq[MAX_AC32_CARDS];
static int mem[MAX_AC32_CARDS];
......@@ -354,26 +395,33 @@ MODULE_LICENSE("GPL");
int
init_module(void)
{
struct net_device *dev;
int this_dev, found = 0;
for (this_dev = 0; this_dev < MAX_AC32_CARDS; this_dev++) {
struct net_device *dev = &dev_ac32[this_dev];
if (io[this_dev] == 0 && this_dev != 0)
break;
dev = alloc_etherdev(0);
if (!dev)
break;
dev->priv = NULL;
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->mem_start = mem[this_dev]; /* Currently ignored by driver */
dev->init = ac3200_probe;
/* Default is to only install one card. */
if (io[this_dev] == 0 && this_dev != 0) break;
if (register_netdev(dev) != 0) {
printk(KERN_WARNING "ac3200.c: No ac3200 card found (i/o = 0x%x).\n", io[this_dev]);
if (found != 0) { /* Got at least one. */
return 0;
if (do_ac3200_probe(dev) == 0) {
if (register_netdev(dev) == 0) {
dev_ac32[found++] = dev;
continue;
}
return -ENXIO;
cleanup_card(dev);
}
found++;
free_netdev(dev);
printk(KERN_WARNING "ac3200.c: No ac3200 card found (i/o = 0x%x).\n", io[this_dev]);
break;
}
return 0;
if (found)
return 0;
return -ENXIO;
}
void
......@@ -382,16 +430,11 @@ cleanup_module(void)
int this_dev;
for (this_dev = 0; this_dev < MAX_AC32_CARDS; this_dev++) {
struct net_device *dev = &dev_ac32[this_dev];
if (dev->priv != NULL) {
/* Someday free_irq may be in ac_close_card() */
free_irq(dev->irq, dev);
release_region(dev->base_addr, AC_IO_EXTENT);
if (ei_status.reg0)
iounmap((void *)dev->mem_start);
struct net_device *dev = dev_ac32[this_dev];
if (dev) {
unregister_netdev(dev);
kfree(dev->priv);
dev->priv = NULL;
cleanup_card(dev);
free_netdev(dev);
}
}
}
......
......@@ -116,28 +116,38 @@ static const char version[] =
static int apne_owned; /* signal if card already owned */
int __init apne_probe(struct net_device *dev)
struct net_device * __init apne_probe(int unit)
{
struct net_device *dev;
#ifndef MANUAL_CONFIG
char tuple[8];
#endif
int err;
if (apne_owned)
return -ENODEV;
SET_MODULE_OWNER(dev);
return ERR_PTR(-ENODEV);
if ( !(AMIGAHW_PRESENT(PCMCIA)) )
return (-ENODEV);
return ERR_PTR(-ENODEV);
printk("Looking for PCMCIA ethernet card : ");
/* check if a card is inserted */
if (!(PCMCIA_INSERTED)) {
printk("NO PCMCIA card inserted\n");
return (-ENODEV);
return ERR_PTR(-ENODEV);
}
dev = alloc_etherdev(0);
if (!dev)
return ERR_PTR(-ENOMEM);
dev->priv = NULL;
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
}
SET_MODULE_OWNER(dev);
/* disable pcmcia irq for readtuple */
pcmcia_disable_irq();
......@@ -145,17 +155,41 @@ int __init apne_probe(struct net_device *dev)
if ((pcmcia_copy_tuple(CISTPL_FUNCID, tuple, 8) < 3) ||
(tuple[2] != CISTPL_FUNCID_NETWORK)) {
printk("not an ethernet card\n");
return (-ENODEV);
/* XXX: shouldn't we re-enable irq here? */
free_netdev(dev);
return ERR_PTR(-ENODEV);
}
#endif
printk("ethernet PCMCIA card inserted\n");
if (init_pcmcia())
return apne_probe1(dev, IOBASE);
else
return (-ENODEV);
if (!init_pcmcia()) {
/* XXX: shouldn't we re-enable irq here? */
free_netdev(dev);
return ERR_PTR(-ENODEV);
}
if (!request_region(IOBASE, 0x20, dev->name)) {
free_netdev(dev);
return ERR_PTR(-EBUSY);
}
err = apne_probe1(dev, IOBASE);
if (err) {
release_region(IOBASE, 0x20);
free_netdev(dev);
return ERR_PTR(err);
}
err = register_netdev(dev);
if (!err)
return dev;
pcmcia_disable_irq();
free_irq(IRQ_AMIGA_PORTS, dev);
pcmcia_reset();
release_region(IOBASE, 0x20);
free_netdev(dev);
return ERR_PTR(err);
}
static int __init apne_probe1(struct net_device *dev, int ioaddr)
......@@ -534,32 +568,29 @@ static irqreturn_t apne_interrupt(int irq, void *dev_id, struct pt_regs *regs)
}
#ifdef MODULE
static struct net_device apne_dev;
static struct net_device *apne_dev;
int init_module(void)
{
int err;
apne_dev.init = apne_probe;
if ((err = register_netdev(&apne_dev))) {
if (err == -EIO)
printk("No PCMCIA NEx000 ethernet card found.\n");
return (err);
}
return (0);
apne_dev = apne_probe(-1);
if (IS_ERR(apne_dev))
return PTR_ERR(apne_dev);
return 0;
}
void cleanup_module(void)
{
unregister_netdev(&apne_dev);
unregister_netdev(apne_dev);
pcmcia_disable_irq();
free_irq(IRQ_AMIGA_PORTS, &apne_dev);
free_irq(IRQ_AMIGA_PORTS, apne_dev);
pcmcia_reset();
apne_owned = 0;
free_netdev(apne_dev);
}
#endif
......
......@@ -81,12 +81,12 @@ static int fmv18x_probe_list[] __initdata = {
*/
#ifndef CONFIG_X86_PC9800
static int at1700_probe_list[] __initdata = {
static unsigned at1700_probe_list[] __initdata = {
0x260, 0x280, 0x2a0, 0x240, 0x340, 0x320, 0x380, 0x300, 0
};
#else /* CONFIG_X86_PC9800 */
static int at1700_probe_list[] __initdata = {
static unsigned at1700_probe_list[] __initdata = {
0x1d6, 0x1d8, 0x1da, 0x1d4, 0xd4, 0xd2, 0xd8, 0xd0, 0
};
......@@ -196,8 +196,6 @@ struct net_local {
/* Index to functions, as function prototypes. */
extern int at1700_probe(struct net_device *dev);
static int at1700_probe1(struct net_device *dev, int ioaddr);
static int read_eeprom(long ioaddr, int location);
static int net_open(struct net_device *dev);
......@@ -232,24 +230,78 @@ static struct at1720_mca_adapters_struct at1720_mca_adapters[] __initdata = {
(detachable devices only).
*/
int __init at1700_probe(struct net_device *dev)
#ifndef CONFIG_X86_PC9800
static int io = 0x260;
#else
static int io = 0xd0;
#endif
static int irq;
static void cleanup_card(struct net_device *dev)
{
int i;
int base_addr = dev->base_addr;
#ifdef CONFIG_MCA
struct net_local *lp = dev->priv;
if (lp->mca_slot)
mca_mark_as_unused(lp->mca_slot);
#endif
free_irq(dev->irq, NULL);
#ifndef CONFIG_X86_PC9800
release_region(dev->base_addr, AT1700_IO_EXTENT);
#else
{
int i;
for (i = 0; i < 0x2000; i += 0x200)
release_region(dev->base_addr + i, 2);
}
#endif
}
SET_MODULE_OWNER(dev);
struct net_device * __init at1700_probe(int unit)
{
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;
} else {
dev->base_addr = io;
dev->irq = irq;
}
if (base_addr > 0x1ff) /* Check a single specified location. */
return at1700_probe1(dev, base_addr);
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
SET_MODULE_OWNER(dev);
for (i = 0; at1700_probe_list[i]; i++) {
int ioaddr = at1700_probe_list[i];
if (at1700_probe1(dev, ioaddr) == 0)
return 0;
if (io > 0x1ff) { /* Check a single specified location. */
err = at1700_probe1(dev, io);
} else if (io != 0) { /* Don't probe at all. */
err = -ENXIO;
} else {
for (port = at1700_probe_list; *port; port++) {
if (at1700_probe1(dev, *port) == 0)
break;
dev->irq = irq;
}
if (!*port)
err = -ENODEV;
}
return -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);
}
/* The Fujitsu datasheet suggests that the NIC be probed for by checking its
......@@ -267,7 +319,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr)
char at1700_irqmap[8] = {3, 4, 5, 9, 10, 11, 14, 15};
unsigned int i, irq, is_fmv18x = 0, is_at1700 = 0;
int slot, ret = -ENODEV;
struct net_local *lp;
struct net_local *lp = dev->priv;
#ifndef CONFIG_X86_PC9800
if (!request_region(ioaddr, AT1700_IO_EXTENT, dev->name))
......@@ -284,9 +336,10 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr)
}
#endif
/* Resetting the chip doesn't reset the ISA interface, so don't bother.
That means we have to be careful with the register values we probe for.
*/
/* Resetting the chip doesn't reset the ISA interface, so don't bother.
That means we have to be careful with the register values we probe
for.
*/
#ifdef notdef
printk("at1700 probe at %#x, eeprom is %4.4x %4.4x %4.4x ctrl %4.4x.\n",
ioaddr, read_eeprom(ioaddr, 4), read_eeprom(ioaddr, 5),
......@@ -331,15 +384,13 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr)
break;
/* probing for a card at a particular IO/IRQ */
if (dev &&
((dev->irq && dev->irq != irq) ||
(dev->base_addr && dev->base_addr != ioaddr))) {
if ((dev->irq && dev->irq != irq) ||
(dev->base_addr && dev->base_addr != ioaddr)) {
slot++; /* probing next slot */
continue;
}
if (dev)
dev->irq = irq;
dev->irq = irq;
/* claim the slot */
mca_set_adapter_name( slot, at1720_mca_adapters[j].name );
......@@ -476,13 +527,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr)
if (net_debug)
printk(version);
/* Initialize the device structure. */
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev->priv == NULL) {
ret = -ENOMEM;
goto err_out;
}
memset(dev->priv, 0, sizeof(struct net_local));
memset(lp, 0, sizeof(struct net_local));
dev->open = net_open;
dev->stop = net_close;
......@@ -492,11 +537,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr)
dev->tx_timeout = net_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
lp = (struct net_local *)dev->priv;
lp->lock = SPIN_LOCK_UNLOCKED;
/* Fill in the fields of 'dev' with ethernet-generic values. */
ether_setup(dev);
spin_lock_init(&lp->lock);
lp->jumpered = is_fmv18x;
lp->mca_slot = slot;
......@@ -505,14 +546,11 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr)
if (ret) {
printk (" AT1700 at %#3x is unusable due to a conflict on"
"IRQ %d.\n", ioaddr, irq);
goto err_out_priv;
goto err_out;
}
return 0;
err_out_priv:
kfree(dev->priv);
dev->priv = NULL;
err_out:
#ifndef CONFIG_X86_PC9800
release_region(ioaddr, AT1700_IO_EXTENT);
......@@ -940,14 +978,7 @@ set_rx_mode(struct net_device *dev)
}
#ifdef MODULE
static struct net_device dev_at1700;
#ifndef CONFIG_X86_PC9800
static int io = 0x260;
#else
static int io = 0xd0;
#endif
static int irq;
static struct net_device *dev_at1700;
MODULE_PARM(io, "i");
MODULE_PARM(irq, "i");
......@@ -960,41 +991,18 @@ int init_module(void)
{
if (io == 0)
printk("at1700: You should not use auto-probing with insmod!\n");
dev_at1700.base_addr = io;
dev_at1700.irq = irq;
dev_at1700.init = at1700_probe;
if (register_netdev(&dev_at1700) != 0) {
printk("at1700: register_netdev() returned non-zero.\n");
return -EIO;
}
dev_at1700 = at1700_probe(-1);
if (IS_ERR(dev_at1700))
return PTR_ERR(dev_at1700);
return 0;
}
void
cleanup_module(void)
{
#ifdef CONFIG_MCA
struct net_local *lp = dev_at1700.priv;
if(lp->mca_slot)
{
mca_mark_as_unused(lp->mca_slot);
}
#endif
unregister_netdev(&dev_at1700);
kfree(dev_at1700.priv);
dev_at1700.priv = NULL;
/* If we don't do this, we can't re-insmod it later. */
free_irq(dev_at1700.irq, NULL);
#ifndef CONFIG_X86_PC9800
release_region(dev_at1700.base_addr, AT1700_IO_EXTENT);
#else
{
int i;
for (i = 0; i < 0x2000; i += 0x200)
release_region(dev_at1700.base_addr + i, 2);
}
#endif
unregister_netdev(dev_at1700);
cleanup_card(dev_at1700);
free_netdev(dev_at1700);
}
#endif /* MODULE */
MODULE_LICENSE("GPL");
......
......@@ -148,8 +148,6 @@ unsigned char *phys_nic_packet;
/* Index to functions, as function prototypes.
*/
extern int bionet_probe(struct net_device *dev);
static int bionet_open(struct net_device *dev);
static int bionet_send_packet(struct sk_buff *skb, struct net_device *dev);
static void bionet_poll_rx(struct net_device *);
......@@ -321,15 +319,26 @@ hardware_send_packet(unsigned long paddr, int cnt) {
/* Check for a network adaptor of this type, and return '0' if one exists.
*/
int __init
bionet_probe(struct net_device *dev){
struct net_device * __init bionet_probe(int unit)
{
struct net_device *dev;
unsigned char station_addr[6];
static unsigned version_printed;
static int no_more_found; /* avoid "Probing for..." printed 4 times */
int i;
int err;
if (!MACH_IS_ATARI || no_more_found)
return -ENODEV;
return ERR_PTR(-ENODEV);
dev = alloc_etherdev(sizeof(struct net_local));
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
}
SET_MODULE_OWNER(dev);
printk("Probing for BioNet 100 Adapter...\n");
......@@ -347,11 +356,10 @@ bionet_probe(struct net_device *dev){
|| station_addr[2] != 'O' ) {
no_more_found = 1;
printk( "No BioNet 100 found.\n" );
return -ENODEV;
free_netdev(dev);
return ERR_PTR(-ENODEV);
}
SET_MODULE_OWNER(dev);
if (bionet_debug > 0 && version_printed++ == 0)
printk(version);
......@@ -369,12 +377,6 @@ bionet_probe(struct net_device *dev){
nic_packet, phys_nic_packet );
}
if (dev->priv == NULL)
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (!dev->priv)
return -ENOMEM;
memset(dev->priv, 0, sizeof(struct net_local));
dev->open = bionet_open;
dev->stop = bionet_close;
dev->hard_start_xmit = bionet_send_packet;
......@@ -390,8 +392,11 @@ bionet_probe(struct net_device *dev){
#endif
dev->dev_addr[i] = station_addr[i];
}
ether_setup(dev);
return 0;
err = register_netdev(dev);
if (!err)
return dev;
free_netdev(dev);
return ERR_PTR(err);
}
/* Open/initialize the board. This is called (in the current kernel)
......@@ -640,25 +645,20 @@ static struct net_device_stats *net_get_stats(struct net_device *dev)
#ifdef MODULE
static struct net_device bio_dev;
int
init_module(void) {
int err;
static struct net_device *bio_dev;
bio_dev.init = bionet_probe;
if ((err = register_netdev(&bio_dev))) {
if (err == -EEXIST) {
printk("BIONET: devices already present. Module not loaded.\n");
}
return err;
}
int init_module(void)
{
bio_dev = bionet_probe(-1);
if (IS_ERR(bio_dev))
return PTR_ERR(bio_dev);
return 0;
}
void
cleanup_module(void) {
unregister_netdev(&bio_dev);
void cleanup_module(void)
{
unregister_netdev(bio_dev);
free_netdev(bio_dev);
}
#endif /* MODULE */
......
......@@ -158,8 +158,6 @@ static int send_1_5 (int lun, unsigned char *command, int dma);
static int get_status (void);
static int calc_received (void *start_address);
extern int pamsnet_probe(struct net_device *dev);
static int pamsnet_open(struct net_device *dev);
static int pamsnet_send_packet(struct sk_buff *skb, struct net_device *dev);
static void pamsnet_poll_rx(struct net_device *);
......@@ -562,12 +560,12 @@ sendpkt (target, buffer, length)
/* Check for a network adaptor of this type, and return '0' if one exists.
*/
int __init
pamsnet_probe (dev)
struct net_device *dev;
struct net_device * __init pamsnet_probe (int unit)
{
struct net_device *dev;
int i;
HADDR *hwaddr;
int err;
unsigned char station_addr[6];
static unsigned version_printed;
......@@ -575,12 +573,18 @@ pamsnet_probe (dev)
static int no_more_found;
if (no_more_found)
return -ENODEV;
return ERR_PTR(-ENODEV);
no_more_found = 1;
dev = alloc_etherdev(sizeof(struct net_local));
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
}
SET_MODULE_OWNER(dev);
no_more_found = 1;
printk("Probing for PAM's Net/GK Adapter...\n");
/* Allocate the DMA buffer here since we need it for probing! */
......@@ -618,11 +622,12 @@ pamsnet_probe (dev)
ENABLE_IRQ();
stdma_release();
if (lance_target < 0)
if (lance_target < 0) {
printk("No PAM's Net/GK found.\n");
free_netdev(dev);
return ERR_PTR(-ENODEV);
}
if ((dev == NULL) || (lance_target < 0))
return -ENODEV;
if (pamsnet_debug > 0 && version_printed++ == 0)
printk(version);
......@@ -632,12 +637,6 @@ pamsnet_probe (dev)
station_addr[3], station_addr[4], station_addr[5]);
/* Initialize the device structure. */
if (dev->priv == NULL)
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (!dev->priv)
return -ENOMEM;
memset(dev->priv, 0, sizeof(struct net_local));
dev->open = pamsnet_open;
dev->stop = pamsnet_close;
dev->hard_start_xmit = pamsnet_send_packet;
......@@ -653,9 +652,12 @@ pamsnet_probe (dev)
#endif
dev->dev_addr[i] = station_addr[i];
}
ether_setup(dev);
err = register_netdev(dev);
if (!err)
return dev;
return(0);
free_netdev(dev);
return ERR_PTR(err);
}
/* Open/initialize the board. This is called (in the current kernel)
......@@ -866,25 +868,20 @@ static struct net_device_stats *net_get_stats(struct net_device *dev)
#ifdef MODULE
static struct net_device pam_dev;
int
init_module(void) {
int err;
static struct net_device *pam_dev;
pam_dev.init = pamsnet_probe;
if ((err = register_netdev(&pam_dev))) {
if (err == -EEXIST) {
printk("PAM's Net/GK: devices already present. Module not loaded.\n");
}
return err;
}
int init_module(void)
{
pam_dev = pamsnet_probe(-1);
if (IS_ERR(pam_dev))
return PTR_ERR(pam_dev);
return 0;
}
void
cleanup_module(void) {
unregister_netdev(&pam_dev);
void cleanup_module(void)
{
unregister_netdev(pam_dev);
free_netdev(pam_dev);
}
#endif /* MODULE */
......
......@@ -371,26 +371,39 @@ static void *slow_memcpy( void *dst, const void *src, size_t len )
}
int __init atarilance_probe( struct net_device *dev )
{
struct net_device * __init atarilance_probe(int unit)
{
int i;
static int found;
SET_MODULE_OWNER(dev);
struct net_device *dev;
int err = -ENODEV;
if (!MACH_IS_ATARI || found)
/* Assume there's only one board possible... That seems true, since
* the Riebl/PAM board's address cannot be changed. */
return( ENODEV );
return ERR_PTR(-ENODEV);
dev = alloc_etherdev(sizeof(struct lance_private));
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
}
SET_MODULE_OWNER(dev);
for( i = 0; i < N_LANCE_ADDR; ++i ) {
if (lance_probe1( dev, &lance_addr_list[i] )) {
found = 1;
return( 0 );
err = register_netdev(dev);
if (!err)
return dev;
free_irq(dev->irq, dev);
break;
}
}
return( ENODEV );
free_netdev(dev);
return ERR_PTR(err);
}
......@@ -511,12 +524,6 @@ static unsigned long __init lance_probe1( struct net_device *dev,
return( 0 );
probe_ok:
init_etherdev( dev, sizeof(struct lance_private) );
if (!dev->priv) {
dev->priv = kmalloc( sizeof(struct lance_private), GFP_KERNEL );
if (!dev->priv)
return 0;
}
lp = (struct lance_private *)dev->priv;
MEM = (struct lance_memory *)memaddr;
IO = lp->iobase = (struct lance_ioreg *)ioaddr;
......@@ -1171,26 +1178,21 @@ static int lance_set_mac_address( struct net_device *dev, void *addr )
#ifdef MODULE
static struct net_device atarilance_dev;
static struct net_device *atarilance_dev;
int init_module(void)
{ int err;
atarilance_dev.init = atarilance_probe;
if ((err = register_netdev( &atarilance_dev ))) {
if (err == -EIO) {
printk( "No Atari Lance board found. Module not loaded.\n");
}
return( err );
}
return( 0 );
{
atarilance_dev = atarilance_probe(-1);
if (IS_ERR(atarilance_dev))
return PTR_ERR(atarilance_dev);
return 0;
}
void cleanup_module(void)
{
unregister_netdev( &atarilance_dev );
unregister_netdev(atarilance_dev);
free_irq(atarilance_dev->irq, atarilance_dev);
free_netdev(atarilance_dev);
}
#endif /* MODULE */
......
......@@ -465,30 +465,43 @@ void *slow_memcpy( void *dst, const void *src, size_t len )
}
int __init bagetlance_probe( struct net_device *dev )
{ int i;
struct net_device * __init bagetlance_probe(int unit)
{
struct net_device *dev;
int i;
static int found;
SET_MODULE_OWNER(dev);
int err = -ENODEV;
if (found)
/* Assume there's only one board possible... That seems true, since
* the Riebl/PAM board's address cannot be changed. */
return( -ENODEV );
return ERR_PTR(-ENODEV);
dev = alloc_etherdev(sizeof(struct lance_private));
if (!dev)
return ERR_PTR(-ENOMEM);
SET_MODULE_OWNER(dev);
for( i = 0; i < N_LANCE_ADDR; ++i ) {
if (lance_probe1( dev, &lance_addr_list[i] )) {
found = 1;
return( 0 );
break;
}
}
return( -ENODEV );
if (!found)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
free_irq(dev->irq, dev);
out:
free_netdev(dev);
return ERR_PTR(err);
}
/* Derived from hwreg_present() in vme/config.c: */
static int __init addr_accessible( volatile void *regp,
......@@ -527,6 +540,7 @@ static int __init lance_probe1( struct net_device *dev,
if (!addr_accessible( memaddr, 1, 1 )) goto probe_fail;
if ((unsigned long)memaddr >= KSEG2) {
/* FIXME: do we need to undo that on cleanup paths? */
extern int kseg2_alloc_io (unsigned long addr, unsigned long size);
if (kseg2_alloc_io((unsigned long)memaddr, BAGET_LANCE_MEM_SIZE)) {
printk("bagetlance: unable map lance memory\n");
......@@ -580,12 +594,6 @@ static int __init lance_probe1( struct net_device *dev,
return( 0 );
probe_ok:
init_etherdev( dev, sizeof(struct lance_private) );
if (!dev->priv) {
dev->priv = kmalloc( sizeof(struct lance_private), GFP_KERNEL );
if (!dev->priv)
return 0;
}
lp = (struct lance_private *)dev->priv;
MEM = (struct lance_memory *)memaddr;
IO = lp->iobase = (struct lance_ioreg *)ioaddr;
......@@ -617,8 +625,9 @@ static int __init lance_probe1( struct net_device *dev,
if (lp->cardtype == PAM_CARD ||
memaddr == (unsigned short *)0xffe00000) {
/* PAMs card and Riebl on ST use level 5 autovector */
request_irq(BAGET_LANCE_IRQ, lance_interrupt, IRQ_TYPE_PRIO,
"PAM/Riebl-ST Ethernet", dev);
if (request_irq(BAGET_LANCE_IRQ, lance_interrupt, IRQ_TYPE_PRIO,
"PAM/Riebl-ST Ethernet", dev))
goto probe_fail;
dev->irq = (unsigned short)BAGET_LANCE_IRQ;
}
else {
......@@ -629,10 +638,11 @@ static int __init lance_probe1( struct net_device *dev,
unsigned long irq = BAGET_LANCE_IRQ;
if (!irq) {
printk( "Lance: request for VME interrupt failed\n" );
return( 0 );
goto probe_fail;
}
request_irq(irq, lance_interrupt, IRQ_TYPE_PRIO,
"Riebl-VME Ethernet", dev);
if (request_irq(irq, lance_interrupt, IRQ_TYPE_PRIO,
"Riebl-VME Ethernet", dev))
goto probe_fail;
dev->irq = irq;
}
......@@ -1331,26 +1341,21 @@ static int lance_set_mac_address( struct net_device *dev, void *addr )
#ifdef MODULE
static struct net_device bagetlance_dev;
static struct net_device *bagetlance_dev;
int init_module(void)
{ int err;
bagetlance_dev.init = bagetlance_probe;
if ((err = register_netdev( &bagetlance_dev ))) {
if (err == -EIO) {
printk( "No Vme Lance board found. Module not loaded.\n");
}
return( err );
}
return( 0 );
{
bagetlance_dev = bagetlance_probe(-1);
if (IS_ERR(bagetlance_dev))
return PTR_ERR(bagetlance_dev);
return 0;
}
void cleanup_module(void)
{
unregister_netdev( &bagetlance_dev );
unregister_netdev(bagetlance_dev);
free_irq(bagetlance_dev->irq, bagetlance_dev);
free_netdev(bagetlance_dev);
}
#endif /* MODULE */
......
......@@ -212,9 +212,7 @@ struct net_local {
/* Index to functions, as function prototypes. */
extern int cs89x0_probe(struct net_device *dev);
static int cs89x0_probe1(struct net_device *dev, int ioaddr);
static int cs89x0_probe1(struct net_device *dev, int ioaddr, int modular);
static int net_open(struct net_device *dev);
static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
......@@ -274,27 +272,51 @@ __setup("cs89x0_media=", media_fn);
Return 0 on success.
*/
int __init cs89x0_probe(struct net_device *dev)
struct net_device * __init cs89x0_probe(int unit)
{
int i;
int base_addr = dev ? dev->base_addr : 0;
struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
unsigned *port;
int err = 0;
int irq;
int io;
SET_MODULE_OWNER(dev);
if (!dev)
return ERR_PTR(-ENODEV);
if (net_debug)
printk("cs89x0:cs89x0_probe(0x%x)\n", base_addr);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
io = dev->base_addr;
irq = dev->irq;
if (base_addr > 0x1ff) /* Check a single specified location. */
return cs89x0_probe1(dev, base_addr);
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
if (net_debug)
printk("cs89x0:cs89x0_probe(0x%x)\n", io);
for (i = 0; netcard_portlist[i]; i++) {
if (cs89x0_probe1(dev, netcard_portlist[i]) == 0)
return 0;
if (io > 0x1ff) { /* Check a single specified location. */
err = cs89x0_probe1(dev, io, 0);
} else if (io != 0) { /* Don't probe at all. */
err = -ENXIO;
} else {
for (port = netcard_portlist; *port; port++) {
if (cs89x0_probe1(dev, *port, 0) == 0)
break;
dev->irq = irq;
}
if (!*port)
err = -ENODEV;
}
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
outw(PP_ChipID, dev->base_addr + ADD_PORT);
release_region(dev->base_addr, NETCARD_IO_EXTENT);
out:
free_netdev(dev);
printk(KERN_WARNING "cs89x0: no cs8900 or cs8920 detected. Be sure to disable PnP with SETUP\n");
return -ENODEV;
return ERR_PTR(err);
}
static int
......@@ -375,39 +397,34 @@ get_eeprom_cksum(int off, int len, int *buffer)
*/
static int __init
cs89x0_probe1(struct net_device *dev, int ioaddr)
cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
{
struct net_local *lp;
struct net_local *lp = (struct net_local *)dev->priv;
static unsigned version_printed;
int i;
unsigned rev_type = 0;
int eeprom_buff[CHKSUM_LEN];
int retval;
SET_MODULE_OWNER(dev);
/* Initialize the device structure. */
if (dev->priv == NULL) {
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev->priv == 0) {
retval = -ENOMEM;
goto out;
}
lp = (struct net_local *)dev->priv;
if (!modular) {
memset(lp, 0, sizeof(*lp));
spin_lock_init(&lp->lock);
#if !defined(MODULE) && (ALLOW_DMA != 0)
#ifndef MODULE
#if ALLOW_DMA
if (g_cs89x0_dma) {
lp->use_dma = 1;
lp->dma = g_cs89x0_dma;
lp->dmasize = 16; /* Could make this an option... */
}
#endif
#ifndef MODULE
lp->force = g_cs89x0_media__force;
#endif
}
lp = (struct net_local *)dev->priv;
/* Grab the region so we can find another board if autoIRQ fails. */
/* WTF is going on here? */
if (!request_region(ioaddr & ~3, NETCARD_IO_EXTENT, dev->name)) {
printk(KERN_ERR "%s: request_region(0x%x, 0x%x) failed\n",
dev->name, ioaddr, NETCARD_IO_EXTENT);
......@@ -696,9 +713,6 @@ printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
dev->set_multicast_list = set_multicast_list;
dev->set_mac_address = set_mac_address;
/* Fill in the fields of the device structure with ethernet values. */
ether_setup(dev);
printk("\n");
if (net_debug)
printk("cs89x0_probe1() successful\n");
......@@ -706,9 +720,6 @@ printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
out2:
release_region(ioaddr & ~3, NETCARD_IO_EXTENT);
out1:
kfree(dev->priv);
dev->priv = 0;
out:
return retval;
}
......@@ -1655,7 +1666,7 @@ static int set_mac_address(struct net_device *dev, void *p)
#ifdef MODULE
static struct net_device dev_cs89x0;
static struct net_device *dev_cs89x0;
/*
* Support the 'debug' module parm even if we're compiled for non-debug to
......@@ -1733,6 +1744,7 @@ MODULE_LICENSE("GPL");
int
init_module(void)
{
struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
struct net_local *lp;
int ret = 0;
......@@ -1741,18 +1753,12 @@ init_module(void)
#else
debug = 0;
#endif
dev_cs89x0.irq = irq;
dev_cs89x0.base_addr = io;
dev_cs89x0.init = cs89x0_probe;
dev_cs89x0.priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev_cs89x0.priv == 0) {
printk(KERN_ERR "cs89x0.c: Out of memory.\n");
if (!dev)
return -ENOMEM;
}
memset(dev_cs89x0.priv, 0, sizeof(struct net_local));
lp = (struct net_local *)dev_cs89x0.priv;
dev->irq = irq;
dev->base_addr = io;
lp = dev->priv;
#if ALLOW_DMA
if (use_dma) {
......@@ -1782,7 +1788,10 @@ init_module(void)
printk(KERN_ERR "cs89x0.c: Append io=0xNNN\n");
ret = -EPERM;
goto out;
}
} else if (io <= 0x1ff) {
ret = -ENXIO;
goto out;
}
#if ALLOW_DMA
if (use_dma && dmasize != 16 && dmasize != 64) {
......@@ -1791,30 +1800,31 @@ init_module(void)
goto out;
}
#endif
ret = cs89x0_probe1(dev, io, 1);
if (ret)
goto out;
if (register_netdev(&dev_cs89x0) != 0) {
if (register_netdev(dev) != 0) {
printk(KERN_ERR "cs89x0.c: No card found at 0x%x\n", io);
ret = -ENXIO;
outw(PP_ChipID, dev->base_addr + ADD_PORT);
release_region(dev->base_addr, NETCARD_IO_EXTENT);
goto out;
}
dev_cs89x0 = dev;
return 0;
out:
if (ret)
kfree(dev_cs89x0.priv);
free_netdev(dev);
return ret;
}
void
cleanup_module(void)
{
if (dev_cs89x0.priv != NULL) {
/* Free up the private structure, or leak memory :-) */
unregister_netdev(&dev_cs89x0);
outw(PP_ChipID, dev_cs89x0.base_addr + ADD_PORT);
kfree(dev_cs89x0.priv);
dev_cs89x0.priv = NULL; /* gets re-allocated by cs89x0_probe1 */
/* If we don't do this, we can't re-insmod it later. */
release_region(dev_cs89x0.base_addr, NETCARD_IO_EXTENT);
}
unregister_netdev(dev_cs89x0);
outw(PP_ChipID, dev_cs89x0->base_addr + ADD_PORT);
release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT);
free_netdev(dev_cs89x0);
}
#endif /* MODULE */
......
......@@ -95,7 +95,6 @@ static inline void mem_off(short port)
#define E21_BIG_RX_STOP_PG 0xF0 /* Last page +1 of RX ring */
#define E21_TX_START_PG E21_RX_STOP_PG /* First page of TX buffer */
int e2100_probe(struct net_device *dev);
static int e21_probe1(struct net_device *dev, int ioaddr);
static int e21_open(struct net_device *dev);
......@@ -117,10 +116,11 @@ static int e21_close(struct net_device *dev);
station address).
*/
int __init e2100_probe(struct net_device *dev)
static int __init do_e2100_probe(struct net_device *dev)
{
int *port;
int base_addr = dev->base_addr;
int irq = dev->irq;
SET_MODULE_OWNER(dev);
......@@ -129,13 +129,50 @@ int __init e2100_probe(struct net_device *dev)
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
for (port = e21_probe_list; *port; port++)
for (port = e21_probe_list; *port; port++) {
dev->irq = irq;
if (e21_probe1(dev, *port) == 0)
return 0;
}
return -ENODEV;
}
static void cleanup_card(struct net_device *dev)
{
void *priv = dev->priv;
/* NB: e21_close() handles free_irq */
release_region(dev->base_addr, E21_IO_EXTENT);
kfree(priv);
}
struct net_device * __init e2100_probe(int unit)
{
struct net_device *dev = alloc_etherdev(0);
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_e2100_probe(dev);
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);
}
static int __init e21_probe1(struct net_device *dev, int ioaddr)
{
int i, status, retval;
......@@ -376,7 +413,7 @@ e21_close(struct net_device *dev)
#ifdef MODULE
#define MAX_E21_CARDS 4 /* Max number of E21 cards per module */
static struct net_device dev_e21[MAX_E21_CARDS];
static struct net_device *dev_e21[MAX_E21_CARDS];
static int io[MAX_E21_CARDS];
static int irq[MAX_E21_CARDS];
static int mem[MAX_E21_CARDS];
......@@ -398,29 +435,36 @@ ISA device autoprobes on a running machine are not recommended. */
int
init_module(void)
{
struct net_device *dev;
int this_dev, found = 0;
for (this_dev = 0; this_dev < MAX_E21_CARDS; this_dev++) {
struct net_device *dev = &dev_e21[this_dev];
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->mem_start = mem[this_dev];
dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
dev->init = e2100_probe;
if (io[this_dev] == 0) {
if (this_dev != 0) break; /* only autoprobe 1st one */
printk(KERN_NOTICE "e2100.c: Presently autoprobing (not recommended) for a single card.\n");
}
if (register_netdev(dev) != 0) {
printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]);
if (found != 0) { /* Got at least one. */
return 0;
dev = alloc_etherdev(0);
if (!dev)
break;
dev->priv = NULL;
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->mem_start = mem[this_dev];
dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
if (do_e2100_probe(dev) == 0) {
if (register_netdev(dev) == 0) {
dev_e21[found++] = dev;
continue;
}
return -ENXIO;
cleanup_card(dev);
}
found++;
free_netdev(dev);
printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]);
break;
}
return 0;
if (found)
return 0;
return -ENXIO;
}
void
......@@ -429,13 +473,11 @@ cleanup_module(void)
int this_dev;
for (this_dev = 0; this_dev < MAX_E21_CARDS; this_dev++) {
struct net_device *dev = &dev_e21[this_dev];
if (dev->priv != NULL) {
void *priv = dev->priv;
/* NB: e21_close() handles free_irq */
release_region(dev->base_addr, E21_IO_EXTENT);
struct net_device *dev = dev_e21[this_dev];
if (dev) {
unregister_netdev(dev);
kfree(priv);
cleanup_card(dev);
free_netdev(dev);
}
}
}
......
This diff is collapsed.
......@@ -244,7 +244,6 @@ static char mca_irqmap[] = { 12, 9, 3, 4, 5, 10, 11, 15 };
* Prototypes for Linux interface
*/
extern int express_probe(struct net_device *dev);
static int eexp_open(struct net_device *dev);
static int eexp_close(struct net_device *dev);
static void eexp_timeout(struct net_device *dev);
......@@ -334,11 +333,13 @@ static inline unsigned short int SHADOW(short int addr)
* checks for presence of EtherExpress card
*/
int __init express_probe(struct net_device *dev)
static int __init do_express_probe(struct net_device *dev)
{
unsigned short *port;
static unsigned short ports[] = { 0x240,0x300,0x310,0x270,0x320,0x340,0 };
unsigned short ioaddr = dev->base_addr;
int dev_irq = dev->irq;
int err;
SET_MODULE_OWNER(dev);
......@@ -391,27 +392,58 @@ int __init express_probe(struct net_device *dev)
}
}
#endif
if (ioaddr&0xfe00)
return eexp_hw_probe(dev,ioaddr);
else if (ioaddr)
if (ioaddr&0xfe00) {
if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress"))
return -EBUSY;
err = eexp_hw_probe(dev,ioaddr);
release_region(ioaddr, EEXP_IO_EXTENT);
return err;
} else if (ioaddr)
return -ENXIO;
for (port=&ports[0] ; *port ; port++ )
{
unsigned short sum = 0;
int i;
if (!request_region(*port, EEXP_IO_EXTENT, "EtherExpress"))
continue;
for ( i=0 ; i<4 ; i++ )
{
unsigned short t;
t = inb(*port + ID_PORT);
sum |= (t>>4) << ((t & 0x03)<<2);
}
if (sum==0xbaba && !eexp_hw_probe(dev,*port))
if (sum==0xbaba && !eexp_hw_probe(dev,*port)) {
release_region(*port, EEXP_IO_EXTENT);
return 0;
}
release_region(*port, EEXP_IO_EXTENT);
dev->irq = dev_irq;
}
return -ENODEV;
}
struct net_device * __init express_probe(int unit)
{
struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
err = do_express_probe(dev);
if (!err) {
err = register_netdev(dev);
if (!err)
return dev;
}
free_netdev(dev);
return ERR_PTR(err);
}
/*
* open and initialize the adapter, ready for use
*/
......@@ -1058,7 +1090,7 @@ static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
unsigned int memory_size;
int i;
unsigned short xsum = 0;
struct net_local *lp;
struct net_local *lp = dev->priv;
printk("%s: EtherExpress 16 at %#x ",dev->name,ioaddr);
......@@ -1108,17 +1140,18 @@ static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
buswidth = !((setupval & 0x400) >> 10);
}
dev->priv = lp = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (!dev->priv)
return -ENOMEM;
memset(dev->priv, 0, sizeof(struct net_local));
memset(lp, 0, sizeof(struct net_local));
spin_lock_init(&lp->lock);
printk("(IRQ %d, %s connector, %d-bit bus", dev->irq,
eexp_ifmap[dev->if_port], buswidth?8:16);
if (!request_region(dev->base_addr + 0x300e, 1, "EtherExpress"))
return -EBUSY;
eexp_hw_set_interface(dev);
release_region(dev->base_addr + 0x300e, 1);
/* Find out how much RAM we have on the card */
outw(0, dev->base_addr + WRITE_PTR);
......@@ -1156,7 +1189,6 @@ static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
break;
default:
printk(") bad memory size (%dk).\n", memory_size);
kfree(dev->priv);
return -ENODEV;
break;
}
......@@ -1171,7 +1203,6 @@ static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
dev->set_multicast_list = &eexp_set_multicast;
dev->tx_timeout = eexp_timeout;
dev->watchdog_timeo = 2*HZ;
ether_setup(dev);
return 0;
}
......@@ -1654,7 +1685,7 @@ eexp_set_multicast(struct net_device *dev)
#define EEXP_MAX_CARDS 4 /* max number of cards to support */
static struct net_device dev_eexp[EEXP_MAX_CARDS];
static struct net_device *dev_eexp[EEXP_MAX_CARDS];
static int irq[EEXP_MAX_CARDS];
static int io[EEXP_MAX_CARDS];
......@@ -1671,25 +1702,30 @@ MODULE_LICENSE("GPL");
*/
int init_module(void)
{
struct net_device *dev;
int this_dev, found = 0;
for (this_dev = 0; this_dev < EEXP_MAX_CARDS; this_dev++) {
struct net_device *dev = &dev_eexp[this_dev];
dev = alloc_etherdev(sizeof(struct net_local));
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->init = express_probe;
if (io[this_dev] == 0) {
if (this_dev) break;
if (this_dev)
break;
printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n");
}
if (register_netdev(dev) != 0) {
printk(KERN_WARNING "eexpress.c: Failed to register card at 0x%x.\n", io[this_dev]);
if (found != 0) return 0;
return -ENXIO;
if (do_express_probe(dev) == 0 && register_netdev(dev) == 0) {
dev_eexp[this_dev] = dev;
found++;
continue;
}
found++;
printk(KERN_WARNING "eexpress.c: Failed to register card at 0x%x.\n", io[this_dev]);
free_netdev(dev);
break;
}
return 0;
if (found)
return 0;
return -ENXIO;
}
void cleanup_module(void)
......@@ -1697,11 +1733,10 @@ void cleanup_module(void)
int this_dev;
for (this_dev = 0; this_dev < EEXP_MAX_CARDS; this_dev++) {
struct net_device *dev = &dev_eexp[this_dev];
if (dev->priv != NULL) {
struct net_device *dev = dev_eexp[this_dev];
if (dev) {
unregister_netdev(dev);
kfree(dev->priv);
dev->priv = NULL;
free_netdev(dev);
}
}
}
......
......@@ -62,7 +62,6 @@ static const char version[] =
#include "8390.h"
int es_probe(struct net_device *dev);
static int es_probe1(struct net_device *dev, int ioaddr);
static int es_open(struct net_device *dev);
......@@ -125,9 +124,11 @@ static unsigned char hi_irq_map[] __initdata = {11, 12, 0, 14, 0, 0, 0, 15};
* PROM for a match against the Racal-Interlan assigned value.
*/
int __init es_probe(struct net_device *dev)
static int __init do_es_probe(struct net_device *dev)
{
unsigned short ioaddr = dev->base_addr;
int irq = dev->irq;
int mem_start = dev->mem_start;
SET_MODULE_OWNER(dev);
......@@ -144,13 +145,50 @@ int __init es_probe(struct net_device *dev)
}
/* EISA spec allows for up to 16 slots, but 8 is typical. */
for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000)
for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
if (es_probe1(dev, ioaddr) == 0)
return 0;
dev->irq = irq;
dev->mem_start = mem_start;
}
return -ENODEV;
}
static void cleanup_card(struct net_device *dev)
{
free_irq(dev->irq, dev);
release_region(dev->base_addr, ES_IO_EXTENT);
kfree(dev->priv);
}
struct net_device * __init es_probe(int unit)
{
struct net_device *dev = alloc_etherdev(0);
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_es_probe(dev);
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);
}
static int __init es_probe1(struct net_device *dev, int ioaddr)
{
int i, retval;
......@@ -376,7 +414,7 @@ static int es_close(struct net_device *dev)
#ifdef MODULE
#define MAX_ES_CARDS 4 /* Max number of ES3210 cards per module */
#define NAMELEN 8 /* # of chars for storing dev->name */
static struct net_device dev_es3210[MAX_ES_CARDS];
static struct net_device *dev_es3210[MAX_ES_CARDS];
static int io[MAX_ES_CARDS];
static int irq[MAX_ES_CARDS];
static int mem[MAX_ES_CARDS];
......@@ -393,26 +431,33 @@ MODULE_LICENSE("GPL");
int
init_module(void)
{
struct net_device *dev;
int this_dev, found = 0;
for (this_dev = 0; this_dev < MAX_ES_CARDS; this_dev++) {
struct net_device *dev = &dev_es3210[this_dev];
if (io[this_dev] == 0 && this_dev != 0)
break;
dev = alloc_etherdev(0);
if (!dev)
break;
dev->priv = NULL;
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->mem_start = mem[this_dev]; /* Currently ignored by driver */
dev->init = es_probe;
/* Default is to only install one card. */
if (io[this_dev] == 0 && this_dev != 0) break;
if (register_netdev(dev) != 0) {
printk(KERN_WARNING "es3210.c: No es3210 card found (i/o = 0x%x).\n", io[this_dev]);
if (found != 0) { /* Got at least one. */
return 0;
dev->mem_start = mem[this_dev];
if (do_es_probe(dev) == 0) {
if (register_netdev(dev) == 0) {
dev_es3210[found++] = dev;
continue;
}
return -ENXIO;
cleanup_card(dev);
}
found++;
free_netdev(dev);
printk(KERN_WARNING "es3210.c: No es3210 card found (i/o = 0x%x).\n", io[this_dev]);
break;
}
return 0;
if (found)
return 0;
return -ENXIO;
}
void
......@@ -421,13 +466,11 @@ cleanup_module(void)
int this_dev;
for (this_dev = 0; this_dev < MAX_ES_CARDS; this_dev++) {
struct net_device *dev = &dev_es3210[this_dev];
if (dev->priv != NULL) {
void *priv = dev->priv;
free_irq(dev->irq, dev);
release_region(dev->base_addr, ES_IO_EXTENT);
struct net_device *dev = dev_es3210[this_dev];
if (dev) {
unregister_netdev(dev);
kfree(priv);
cleanup_card(dev);
free_netdev(dev);
}
}
}
......
......@@ -369,7 +369,6 @@ static unsigned int eth32i_irqmap[] __initdata = { 3, 5, 7, 9, 10, 11, 12, 15, 0
#define NUM_OF_EISA_IRQS 8
static unsigned int eth16i_tx_buf_map[] = { 2048, 2048, 4096, 8192 };
static unsigned int boot = 1;
/* Use 0 for production, 1 for verification, >2 for debug */
#ifndef ETH16I_DEBUG
......@@ -395,8 +394,6 @@ struct eth16i_local {
/* Function prototypes */
extern int eth16i_probe(struct net_device *dev);
static int eth16i_probe1(struct net_device *dev, int ioaddr);
static int eth16i_check_signature(int ioaddr);
static int eth16i_probe_port(int ioaddr);
......@@ -418,7 +415,7 @@ static void eth16i_timeout(struct net_device *dev);
static void eth16i_skip_packet(struct net_device *dev);
static void eth16i_multicast(struct net_device *dev);
static void eth16i_select_regbank(unsigned char regbank, int ioaddr);
static void eth16i_initialize(struct net_device *dev);
static void eth16i_initialize(struct net_device *dev, int boot);
#if 0
static int eth16i_set_irq(struct net_device *dev);
......@@ -432,7 +429,7 @@ static struct net_device_stats *eth16i_get_stats(struct net_device *dev);
static char cardname[] __initdata = "ICL EtherTeam 16i/32";
int __init eth16i_probe(struct net_device *dev)
static int __init do_eth16i_probe(struct net_device *dev)
{
int i;
int ioaddr;
......@@ -461,14 +458,38 @@ int __init eth16i_probe(struct net_device *dev)
return -ENODEV;
}
struct net_device * __init eth16i_probe(int unit)
{
struct net_device *dev = alloc_etherdev(sizeof(struct eth16i_local));
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
err = do_eth16i_probe(dev);
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
free_irq(dev->irq, dev);
release_region(dev->base_addr, ETH16I_IO_EXTENT);
out:
free_netdev(dev);
return ERR_PTR(err);
}
static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
{
struct eth16i_local *lp;
struct eth16i_local *lp = dev->priv;
static unsigned version_printed;
int retval;
boot = 1; /* To inform initilization that we are in boot probe */
/* Let's grab the region */
if (!request_region(ioaddr, ETH16I_IO_EXTENT, dev->name))
return -EBUSY;
......@@ -531,22 +552,13 @@ static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
eth16i_select_regbank(TRANSCEIVER_MODE_RB, ioaddr);
outb(0x38, ioaddr + TRANSCEIVER_MODE_REG);
eth16i_initialize(dev); /* Initialize rest of the chip's registers */
eth16i_initialize(dev, 1); /* Initialize rest of the chip's registers */
/* Now let's same some energy by shutting down the chip ;) */
BITCLR(ioaddr + CONFIG_REG_1, POWERUP);
/* Initialize the device structure */
if(dev->priv == NULL) {
dev->priv = kmalloc(sizeof(struct eth16i_local), GFP_KERNEL);
if(dev->priv == NULL) {
free_irq(dev->irq, dev);
retval = -ENOMEM;
goto out;
}
}
memset(dev->priv, 0, sizeof(struct eth16i_local));
memset(lp, 0, sizeof(struct eth16i_local));
dev->open = eth16i_open;
dev->stop = eth16i_close;
dev->hard_start_xmit = eth16i_tx;
......@@ -554,15 +566,7 @@ static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
dev->set_multicast_list = eth16i_multicast;
dev->tx_timeout = eth16i_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
lp = (struct eth16i_local *)dev->priv;
spin_lock_init(&lp->lock);
/* Fill in the fields of the device structure with ethernet values. */
ether_setup(dev);
boot = 0;
return 0;
out:
release_region(ioaddr, ETH16I_IO_EXTENT);
......@@ -570,7 +574,7 @@ static int __init eth16i_probe1(struct net_device *dev, int ioaddr)
}
static void eth16i_initialize(struct net_device *dev)
static void eth16i_initialize(struct net_device *dev, int boot)
{
int ioaddr = dev->base_addr;
int i, node_w = 0;
......@@ -953,7 +957,7 @@ static int eth16i_open(struct net_device *dev)
outb(0xc0 | POWERUP, ioaddr + CONFIG_REG_1);
/* Initialize the chip */
eth16i_initialize(dev);
eth16i_initialize(dev, 0);
/* Set the transmit buffer size */
lp->tx_buf_size = eth16i_tx_buf_map[ETH16I_TX_BUF_SIZE & 0x03];
......@@ -1401,7 +1405,7 @@ static ushort eth16i_parse_mediatype(const char* s)
#define MAX_ETH16I_CARDS 4 /* Max number of Eth16i cards per module */
static struct net_device dev_eth16i[MAX_ETH16I_CARDS];
static struct net_device *dev_eth16i[MAX_ETH16I_CARDS];
static int io[MAX_ETH16I_CARDS];
#if 0
static int irq[MAX_ETH16I_CARDS];
......@@ -1431,14 +1435,14 @@ MODULE_PARM_DESC(debug, "eth16i debug level (0-6)");
int init_module(void)
{
int this_dev, found = 0;
struct net_device *dev;
for (this_dev = 0; this_dev < MAX_ETH16I_CARDS; this_dev++) {
dev = alloc_etherdev(sizeof(struct eth16i_local));
if (!dev)
break;
for(this_dev = 0; this_dev < MAX_ETH16I_CARDS; this_dev++)
{
struct net_device *dev = &dev_eth16i[this_dev];
dev->irq = 0; /* irq[this_dev]; */
dev->base_addr = io[this_dev];
dev->init = eth16i_probe;
if(debug != -1)
eth16i_debug = debug;
......@@ -1448,44 +1452,43 @@ int init_module(void)
dev->if_port = eth16i_parse_mediatype(mediatype[this_dev]);
if(io[this_dev] == 0)
{
if(this_dev != 0) break; /* Only autoprobe 1st one */
if(io[this_dev] == 0) {
if(this_dev != 0) /* Only autoprobe 1st one */
break;
printk(KERN_NOTICE "eth16i.c: Presently autoprobing (not recommended) for a single card.\n");
}
if(register_netdev(dev) != 0)
{
printk(KERN_WARNING "eth16i.c No Eth16i card found (i/o = 0x%x).\n",
io[this_dev]);
if(found != 0) return 0;
return -ENXIO;
if (do_eth16i_probe(dev) == 0) {
if (register_netdev(dev) == 0) {
dev_eth16i[found++] = dev;
continue;
}
free_irq(dev->irq, dev);
release_region(dev->base_addr, ETH16I_IO_EXTENT);
}
found++;
printk(KERN_WARNING "eth16i.c No Eth16i card found (i/o = 0x%x).\n",
io[this_dev]);
free_netdev(dev);
break;
}
return 0;
if (found)
return 0;
return -ENXIO;
}
void cleanup_module(void)
{
int this_dev;
for(this_dev = 0; this_dev < MAX_ETH16I_CARDS; this_dev++)
{
struct net_device* dev = &dev_eth16i[this_dev];
for(this_dev = 0; this_dev < MAX_ETH16I_CARDS; this_dev++) {
struct net_device *dev = dev_eth16i[this_dev];
if(dev->priv != NULL)
{
if(dev->priv) {
unregister_netdev(dev);
kfree(dev->priv);
dev->priv = NULL;
free_irq(dev->irq, dev);
release_region(dev->base_addr, ETH16I_IO_EXTENT);
free_netdev(dev);
}
}
}
......
This diff is collapsed.
......@@ -57,7 +57,7 @@ static const char version[] =
#include <asm/io.h>
#include <asm/dma.h>
static int fmv18x_probe_list[] __initdata = {
static unsigned fmv18x_probe_list[] __initdata = {
0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x300, 0x340, 0
};
......@@ -109,8 +109,6 @@ struct net_local {
/* Index to functions, as function prototypes. */
extern int fmv18x_probe(struct net_device *dev);
static int fmv18x_probe1(struct net_device *dev, short ioaddr);
static int net_open(struct net_device *dev);
static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
......@@ -129,23 +127,50 @@ static void set_multicast_list(struct net_device *dev);
(detachable devices only).
*/
int __init fmv18x_probe(struct net_device *dev)
static int io = 0x220;
static int irq;
struct net_device * __init fmv18x_probe(int unit)
{
int i;
int base_addr = dev->base_addr;
struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
unsigned *port;
int err = 0;
SET_MODULE_OWNER(dev);
if (!dev)
return ERR_PTR(-ENODEV);
if (base_addr > 0x1ff) /* Check a single specified location. */
return fmv18x_probe1(dev, base_addr);
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
io = dev->base_addr;
irq = dev->irq;
}
for (i = 0; fmv18x_probe_list[i]; i++)
if (fmv18x_probe1(dev, fmv18x_probe_list[i]) == 0)
return 0;
SET_MODULE_OWNER(dev);
return -ENODEV;
if (io > 0x1ff) { /* Check a single specified location. */
err = fmv18x_probe1(dev, io);
} else if (io != 0) { /* Don't probe at all. */
err = -ENXIO;
} else {
for (port = fmv18x_probe_list; *port; port++)
if (fmv18x_probe1(dev, *port) == 0)
break;
if (!*port)
err = -ENODEV;
}
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
free_irq(dev->irq, dev);
release_region(dev->base_addr, FMV18X_IO_EXTENT);
out:
free_netdev(dev);
return ERR_PTR(err);
}
/* The Fujitsu datasheet suggests that the NIC be probed for by checking its
......@@ -160,7 +185,7 @@ static int __init fmv18x_probe1(struct net_device *dev, short ioaddr)
{
char irqmap[4] = {3, 7, 10, 15};
char irqmap_pnp[8] = {3, 4, 5, 7, 9, 10, 11, 15};
unsigned int i, irq, retval;
unsigned int i, retval;
struct net_local *lp;
/* Resetting the chip doesn't reset the ISA interface, so don't bother.
......@@ -170,6 +195,9 @@ static int __init fmv18x_probe1(struct net_device *dev, short ioaddr)
if (!request_region(ioaddr, FMV18X_IO_EXTENT, dev->name))
return -EBUSY;
dev->irq = irq;
dev->base_addr = ioaddr;
/* Check I/O address configuration and Fujitsu vendor code */
if (inb(ioaddr+FJ_MACADDR ) != 0x00
|| inb(ioaddr+FJ_MACADDR+1) != 0x00
......@@ -181,9 +209,8 @@ static int __init fmv18x_probe1(struct net_device *dev, short ioaddr)
/* Check PnP mode for FMV-183/184/183A/184A. */
/* This PnP routine is very poor. IO and IRQ should be known. */
if (inb(ioaddr + FJ_STATUS1) & 0x20) {
irq = dev->irq;
for (i = 0; i < 8; i++) {
if (irq == irqmap_pnp[i])
if (dev->irq == irqmap_pnp[i])
break;
}
if (i == 8) {
......@@ -193,22 +220,19 @@ static int __init fmv18x_probe1(struct net_device *dev, short ioaddr)
} else {
if (fmv18x_probe_list[inb(ioaddr + FJ_CONFIG0) & 0x07] != ioaddr)
return -ENODEV;
irq = irqmap[(inb(ioaddr + FJ_CONFIG0)>>6) & 0x03];
dev->irq = irqmap[(inb(ioaddr + FJ_CONFIG0)>>6) & 0x03];
}
/* Snarf the interrupt vector now. */
retval = request_irq(irq, &net_interrupt, 0, dev->name, dev);
retval = request_irq(dev->irq, &net_interrupt, 0, dev->name, dev);
if (retval) {
printk ("FMV-18x found at %#3x, but it's unusable due to a conflict on"
"IRQ %d.\n", ioaddr, irq);
"IRQ %d.\n", ioaddr, dev->irq);
goto out;
}
printk("%s: FMV-18x found at %#3x, IRQ %d, address ", dev->name,
ioaddr, irq);
dev->base_addr = ioaddr;
dev->irq = irq;
ioaddr, dev->irq);
for(i = 0; i < 6; i++) {
unsigned char val = inb(ioaddr + FJ_MACADDR + i);
......@@ -279,14 +303,10 @@ static int __init fmv18x_probe1(struct net_device *dev, short ioaddr)
dev->watchdog_timeo = HZ/10;
dev->get_stats = net_get_stats;
dev->set_multicast_list = set_multicast_list;
/* Fill in the fields of 'dev' with ethernet-generic values. */
ether_setup(dev);
return 0;
out_irq:
free_irq(irq, dev);
free_irq(dev->irq, dev);
out:
release_region(ioaddr, FMV18X_IO_EXTENT);
return retval;
......@@ -413,9 +433,7 @@ static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
lp->tx_queue_len = 0;
dev->trans_start = jiffies;
lp->tx_started = 1;
} else if (lp->tx_queue_len < 4096 - 1502)
/* Yes, there is room for one more packet. */
else
} else if (lp->tx_queue_len >= 4096 - 1502) /* No room for a packet */
netif_stop_queue(dev);
dev_kfree_skb(skb);
......@@ -628,9 +646,7 @@ static void set_multicast_list(struct net_device *dev)
}
#ifdef MODULE
static struct net_device dev_fmv18x;
static int io = 0x220;
static int irq;
static struct net_device *dev_fmv18x;
MODULE_PARM(io, "i");
MODULE_PARM(irq, "i");
......@@ -644,26 +660,19 @@ int init_module(void)
{
if (io == 0)
printk("fmv18x: You should not use auto-probing with insmod!\n");
dev_fmv18x.base_addr = io;
dev_fmv18x.irq = irq;
dev_fmv18x.init = fmv18x_probe;
if (register_netdev(&dev_fmv18x) != 0) {
printk("fmv18x: register_netdev() returned non-zero.\n");
return -EIO;
}
dev_fmv18x = fmv18x_probe(-1);
if (IS_ERR(dev_fmv18x))
return PTR_ERR(dev_fmv18x);
return 0;
}
void
cleanup_module(void)
{
unregister_netdev(&dev_fmv18x);
kfree(dev_fmv18x.priv);
dev_fmv18x.priv = NULL;
/* If we don't do this, we can't re-insmod it later. */
free_irq(dev_fmv18x.irq, &dev_fmv18x);
release_region(dev_fmv18x.base_addr, FMV18X_IO_EXTENT);
unregister_netdev(dev_fmv18x);
free_irq(dev_fmv18x->irq, dev_fmv18x);
release_region(dev_fmv18x->base_addr, FMV18X_IO_EXTENT);
free_netdev(dev_fmv18x);
}
#endif /* MODULE */
......
......@@ -92,7 +92,6 @@ enum HP_Option {
EnableIRQ = 4, FakeIntr = 8, BootROMEnb = 0x10, IOEnb = 0x20,
MemEnable = 0x40, ZeroWait = 0x80, MemDisable = 0x1000, };
int hp_plus_probe(struct net_device *dev);
static int hpp_probe1(struct net_device *dev, int ioaddr);
static void hpp_reset_8390(struct net_device *dev);
......@@ -115,10 +114,11 @@ static void hpp_io_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hd
/* Probe a list of addresses for an HP LAN+ adaptor.
This routine is almost boilerplate. */
int __init hp_plus_probe(struct net_device *dev)
static int __init do_hpp_probe(struct net_device *dev)
{
int i;
int base_addr = dev->base_addr;
int irq = dev->irq;
SET_MODULE_OWNER(dev);
......@@ -127,13 +127,49 @@ int __init hp_plus_probe(struct net_device *dev)
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
for (i = 0; hpplus_portlist[i]; i++)
for (i = 0; hpplus_portlist[i]; i++) {
if (hpp_probe1(dev, hpplus_portlist[i]) == 0)
return 0;
dev->irq = irq;
}
return -ENODEV;
}
static void cleanup_card(struct net_device *dev)
{
/* NB: hpp_close() handles free_irq */
release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
kfree(dev->priv);
}
struct net_device * __init hp_plus_probe(int unit)
{
struct net_device *dev = alloc_etherdev(0);
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_hpp_probe(dev);
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);
}
/* Do the interesting part of the probe at a single address. */
static int __init hpp_probe1(struct net_device *dev, int ioaddr)
{
......@@ -400,7 +436,7 @@ hpp_mem_block_output(struct net_device *dev, int count,
#ifdef MODULE
#define MAX_HPP_CARDS 4 /* Max number of HPP cards per module */
static struct net_device dev_hpp[MAX_HPP_CARDS];
static struct net_device *dev_hpp[MAX_HPP_CARDS];
static int io[MAX_HPP_CARDS];
static int irq[MAX_HPP_CARDS];
......@@ -416,27 +452,34 @@ ISA device autoprobes on a running machine are not recommended. */
int
init_module(void)
{
struct net_device *dev;
int this_dev, found = 0;
for (this_dev = 0; this_dev < MAX_HPP_CARDS; this_dev++) {
struct net_device *dev = &dev_hpp[this_dev];
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->init = hp_plus_probe;
if (io[this_dev] == 0) {
if (this_dev != 0) break; /* only autoprobe 1st one */
printk(KERN_NOTICE "hp-plus.c: Presently autoprobing (not recommended) for a single card.\n");
}
if (register_netdev(dev) != 0) {
printk(KERN_WARNING "hp-plus.c: No HP-Plus card found (i/o = 0x%x).\n", io[this_dev]);
if (found != 0) { /* Got at least one. */
return 0;
dev = alloc_etherdev(0);
if (!dev)
break;
dev->priv = NULL;
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
if (do_hpp_probe(dev) == 0) {
if (register_netdev(dev) == 0) {
dev_hpp[found++] = dev;
continue;
}
return -ENXIO;
cleanup_card(dev);
}
found++;
free_netdev(dev);
printk(KERN_WARNING "hp-plus.c: No HP-Plus card found (i/o = 0x%x).\n", io[this_dev]);
break;
}
return 0;
if (found)
return 0;
return -ENXIO;
}
void
......@@ -445,14 +488,11 @@ cleanup_module(void)
int this_dev;
for (this_dev = 0; this_dev < MAX_HPP_CARDS; this_dev++) {
struct net_device *dev = &dev_hpp[this_dev];
if (dev->priv != NULL) {
int ioaddr = dev->base_addr - NIC_OFFSET;
void *priv = dev->priv;
/* NB: hpp_close() handles free_irq */
release_region(ioaddr, HP_IO_EXTENT);
struct net_device *dev = dev_hpp[this_dev];
if (dev) {
unregister_netdev(dev);
kfree(priv);
cleanup_card(dev);
free_netdev(dev);
}
}
}
......
......@@ -55,7 +55,6 @@ static unsigned int hppclan_portlist[] __initdata =
#define HP_8BSTOP_PG 0x80 /* Last page +1 of RX ring */
#define HP_16BSTOP_PG 0xFF /* Same, for 16 bit cards. */
int hp_probe(struct net_device *dev);
static int hp_probe1(struct net_device *dev, int ioaddr);
static int hp_open(struct net_device *dev);
......@@ -79,10 +78,11 @@ static char irqmap[16] __initdata= { 0, 0, 4, 6, 8,10, 0,14, 0, 4, 2,12,0,0,0,0}
Also initialize the card and fill in STATION_ADDR with the station
address. */
int __init hp_probe(struct net_device *dev)
static int __init do_hp_probe(struct net_device *dev)
{
int i;
int base_addr = dev->base_addr;
int irq = dev->irq;
SET_MODULE_OWNER(dev);
......@@ -91,13 +91,49 @@ int __init hp_probe(struct net_device *dev)
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
for (i = 0; hppclan_portlist[i]; i++)
for (i = 0; hppclan_portlist[i]; i++) {
if (hp_probe1(dev, hppclan_portlist[i]) == 0)
return 0;
dev->irq = irq;
}
return -ENODEV;
}
static void cleanup_card(struct net_device *dev)
{
free_irq(dev->irq, dev);
release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
kfree(dev->priv);
}
struct net_device * __init hp_probe(int unit)
{
struct net_device *dev = alloc_etherdev(0);
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
dev->priv = NULL; /* until all 8390-based use alloc_etherdev() */
err = do_hp_probe(dev);
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);
}
static int __init hp_probe1(struct net_device *dev, int ioaddr)
{
int i, retval, board_id, wordmode;
......@@ -372,7 +408,7 @@ hp_init_card(struct net_device *dev)
#ifdef MODULE
#define MAX_HP_CARDS 4 /* Max number of HP cards per module */
static struct net_device dev_hp[MAX_HP_CARDS];
static struct net_device *dev_hp[MAX_HP_CARDS];
static int io[MAX_HP_CARDS];
static int irq[MAX_HP_CARDS];
......@@ -388,27 +424,34 @@ ISA device autoprobes on a running machine are not recommended. */
int
init_module(void)
{
struct net_device *dev;
int this_dev, found = 0;
for (this_dev = 0; this_dev < MAX_HP_CARDS; this_dev++) {
struct net_device *dev = &dev_hp[this_dev];
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->init = hp_probe;
if (io[this_dev] == 0) {
if (this_dev != 0) break; /* only autoprobe 1st one */
printk(KERN_NOTICE "hp.c: Presently autoprobing (not recommended) for a single card.\n");
}
if (register_netdev(dev) != 0) {
printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]);
if (found != 0) { /* Got at least one. */
return 0;
dev = alloc_etherdev(0);
if (!dev)
break;
dev->priv = NULL;
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
if (do_hp_probe(dev) == 0) {
if (register_netdev(dev) == 0) {
dev_hp[found++] = dev;
continue;
}
return -ENXIO;
cleanup_card(dev);
}
found++;
free_netdev(dev);
printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]);
break;
}
return 0;
if (found)
return 0;
return -ENXIO;
}
void
......@@ -417,14 +460,11 @@ cleanup_module(void)
int this_dev;
for (this_dev = 0; this_dev < MAX_HP_CARDS; this_dev++) {
struct net_device *dev = &dev_hp[this_dev];
if (dev->priv != NULL) {
int ioaddr = dev->base_addr - NIC_OFFSET;
void *priv = dev->priv;
free_irq(dev->irq, dev);
release_region(ioaddr, HP_IO_EXTENT);
struct net_device *dev = dev_hp[this_dev];
if (dev) {
unregister_netdev(dev);
kfree(priv);
cleanup_card(dev);
free_netdev(dev);
}
}
}
......
This diff is collapsed.
......@@ -50,8 +50,7 @@ struct hplance_private {
* plus board-specific init, open and close actions.
* Oh, and we need to tell the generic code how to read and write LANCE registers...
*/
int hplance_probe(struct net_device *dev);
static int hplance_init(struct net_device *dev, int scode);
static void hplance_init(struct net_device *dev, int scode);
static int hplance_open(struct net_device *dev);
static int hplance_close(struct net_device *dev);
static void hplance_writerap(void *priv, unsigned short value);
......@@ -62,57 +61,61 @@ static unsigned short hplance_readrdp(void *priv);
static struct hplance_private *root_hplance_dev;
#endif
static void cleanup_card(struct net_device *dev)
{
struct hplance_private *lp = dev->priv;
dio_unconfig_board(lp->scode);
}
/* Find all the HP Lance boards and initialise them... */
int __init hplance_probe(struct net_device *dev)
struct net_device * __init hplance_probe(int unit)
{
int cards = 0, called = 0;
struct net_device *dev;
if (!MACH_IS_HP300)
return ERR_PTR(-ENODEV);
dev = alloc_etherdev(sizeof(struct hplance_private));
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
}
if (!MACH_IS_HP300 || called)
return(ENODEV);
called++;
SET_MODULE_OWNER(dev);
/* Isn't DIO nice? */
for(;;)
{
int v, scode = dio_find(DIO_ID_LAN);
int scode = dio_find(DIO_ID_LAN);
if (!scode)
break;
if(cards)
dev = NULL; /* don't trash previous device, make a new one */
cards++;
v = hplance_init(dev, scode);
if (v) /* error, abort immediately */
return v;
dio_config_board(scode);
hplance_init(dev, scode);
if (!register_netdev(dev)) {
struct hplance_private *lp = dev->priv;
lp->next_module = root_hplance_dev;
root_hplance_dev = lp;
return dev;
}
cleanup_card(dev);
}
/* OK, return success, or ENODEV if we didn't find any cards */
if (!cards)
return -ENODEV;
return 0;
free_netdev(dev);
return ERR_PTR(-ENODEV);
}
/* Initialise a single lance board at the given select code */
static int __init hplance_init(struct net_device *dev, int scode)
static void __init hplance_init(struct net_device *dev, int scode)
{
const char *name = dio_scodetoname(scode);
void *va = dio_scodetoviraddr(scode);
struct hplance_private *lp;
int i;
#ifdef MODULE
dev = init_etherdev(0, sizeof(struct hplance_private));
if (!dev)
return -ENOMEM;
#else
dev->priv = kmalloc(sizeof(struct hplance_private), GFP_KERNEL);
if (dev->priv == NULL)
return -ENOMEM;
memset(dev->priv, 0, sizeof(struct hplance_private));
#endif
SET_MODULE_OWNER(dev);
printk("%s: %s; select code %d, addr", dev->name, name, scode);
/* reset the board */
......@@ -154,17 +157,7 @@ static int __init hplance_init(struct net_device *dev, int scode)
lp->lance.tx_ring_mod_mask = TX_RING_MOD_MASK;
lp->scode = scode;
lp->base = va;
ether_setup(dev);
printk(", irq %d\n", lp->lance.irq);
#ifdef MODULE
dev->ifindex = dev_new_index();
lp->next_module = root_hplance_dev;
root_hplance_dev = lp;
#endif /* MODULE */
dio_config_board(scode); /* tell bus scanning code this one's taken */
return 0;
}
/* This is disgusting. We have to check the DIO status register for ack every
......@@ -227,8 +220,10 @@ static int hplance_close(struct net_device *dev)
MODULE_LICENSE("GPL");
int init_module(void)
{
root_lance_dev = NULL;
return hplance_probe(NULL);
int found = 0;
while (!IS_ERR(hplance_probe(-1)))
found++;
return found ? 0 : -ENODEV;
}
void cleanup_module(void)
......@@ -237,8 +232,8 @@ void cleanup_module(void)
struct hplance_private *lp;
while (root_hplance_dev) {
lp = root_hplance_dev->next_module;
dio_unconfig_board(lp->scode);
unregister_netdev(root_lance_dev->dev);
cleanup_card(root_lance_dev->dev);
free_netdev(root_lance_dev->dev);
root_lance_dev = lp;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -477,5 +477,5 @@ static void __init ne2k_cbus_writemem(struct net_device *dev, int ioaddr, unsign
}
#endif
static int ne_probe_cbus(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr);
static int ne_probe_cbus(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr, int irq);
/* End of ne2k_cbus.h */
This diff is collapsed.
This diff is collapsed.
......@@ -178,7 +178,4 @@ typedef struct { /* LANCE Rx descriptor */
#endif /* _SK_MCA_DRIVER_ */
extern int skmca_probe(struct net_device *);
#endif /* _SK_MCA_INCLUDE_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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