Commit 72f64a05 authored by Jeff Garzik's avatar Jeff Garzik

Merge redhat.com:/spare/repo/linux-2.5

into redhat.com:/spare/repo/netdev-2.6/netdev-alloc-1
parents 0010bc50 5d40d90f
......@@ -136,17 +136,14 @@ static const char version[] =
#include "3c501.h"
/* A zero-terminated list of I/O addresses to be probed.
The 3c501 can be at many locations, but here are the popular ones. */
static unsigned int netcard_portlist[] __initdata = {
0x280, 0x300, 0
};
/*
* The boilerplate probe code.
*/
static int io=0x280;
static int irq=5;
static int mem_start;
/**
* el1_probe: - probe for a 3c501
* @dev: The device structure passed in to probe.
......@@ -160,23 +157,47 @@ static unsigned int netcard_portlist[] __initdata = {
* probe and failing to find anything.
*/
int __init el1_probe(struct net_device *dev)
struct net_device * __init el1_probe(int unit)
{
int i;
int base_addr = dev->base_addr;
struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
static unsigned ports[] = { 0x280, 0x300, 0};
unsigned *port;
int err = 0;
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
io = dev->base_addr;
irq = dev->irq;
mem_start = dev->mem_start & 7;
}
SET_MODULE_OWNER(dev);
if (base_addr > 0x1ff) /* Check a single specified location. */
return el1_probe1(dev, base_addr);
else if (base_addr != 0) /* Don't probe at all. */
return -ENXIO;
for (i = 0; netcard_portlist[i]; i++)
if (el1_probe1(dev, netcard_portlist[i]) == 0)
return 0;
return -ENODEV;
if (io > 0x1ff) { /* Check a single specified location. */
err = el1_probe1(dev, io);
} else if (io != 0) {
err = -ENXIO; /* Don't probe at all. */
} else {
for (port = ports; *port && el1_probe1(dev, *port); port++)
;
if (!*port)
err = -ENODEV;
}
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
release_region(dev->base_addr, EL1_IO_EXTENT);
out:
free_netdev(dev);
return ERR_PTR(err);
}
/**
......@@ -240,6 +261,8 @@ static int __init el1_probe1(struct net_device *dev, int ioaddr)
* high.
*/
dev->irq = irq;
if (dev->irq < 2)
{
unsigned long irq_mask;
......@@ -267,8 +290,8 @@ static int __init el1_probe1(struct net_device *dev, int ioaddr)
dev->base_addr = ioaddr;
memcpy(dev->dev_addr, station_addr, ETH_ALEN);
if (dev->mem_start & 0xf)
el_debug = dev->mem_start & 0x7;
if (mem_start & 0xf)
el_debug = mem_start & 0x7;
if (autoirq)
dev->irq = autoirq;
......@@ -282,17 +305,7 @@ static int __init el1_probe1(struct net_device *dev, int ioaddr)
if (el_debug)
printk(KERN_DEBUG "%s", version);
/*
* Initialize the device structure.
*/
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev->priv == NULL) {
release_region(ioaddr, EL1_IO_EXTENT);
return -ENOMEM;
}
memset(dev->priv, 0, sizeof(struct net_local));
lp=dev->priv;
spin_lock_init(&lp->lock);
......@@ -308,13 +321,6 @@ static int __init el1_probe1(struct net_device *dev, int ioaddr)
dev->get_stats = &el1_get_stats;
dev->set_multicast_list = &set_multicast_list;
dev->ethtool_ops = &netdev_ethtool_ops;
/*
* Setup the generic properties
*/
ether_setup(dev);
return 0;
}
......@@ -884,14 +890,8 @@ static struct ethtool_ops netdev_ethtool_ops = {
#ifdef MODULE
static struct net_device dev_3c501 = {
.init = el1_probe,
.base_addr = 0x280,
.irq = 5,
};
static struct net_device *dev_3c501;
static int io=0x280;
static int irq=5;
MODULE_PARM(io, "i");
MODULE_PARM(irq, "i");
MODULE_PARM_DESC(io, "EtherLink I/O base address");
......@@ -911,10 +911,9 @@ MODULE_PARM_DESC(irq, "EtherLink IRQ number");
int init_module(void)
{
dev_3c501.irq=irq;
dev_3c501.base_addr=io;
if (register_netdev(&dev_3c501) != 0)
return -EIO;
dev_3c501 = el1_probe(-1);
if (IS_ERR(dev_3c501))
return PTR_ERR(dev_3c501);
return 0;
}
......@@ -927,19 +926,10 @@ int init_module(void)
void cleanup_module(void)
{
unregister_netdev(&dev_3c501);
/*
* Free up the private structure, or leak memory :-)
*/
kfree(dev_3c501.priv);
dev_3c501.priv = NULL; /* gets re-allocated by el1_probe1 */
/*
* If we don't do this, we can't re-insmod it later.
*/
release_region(dev_3c501.base_addr, EL1_IO_EXTENT);
struct net_device *dev = dev_3c501;
unregister_netdev(dev);
release_region(dev->base_addr, EL1_IO_EXTENT);
free_netdev(dev);
}
#endif /* MODULE */
......
......@@ -3,7 +3,6 @@
* Index to functions.
*/
int el1_probe(struct net_device *dev);
static int el1_probe1(struct net_device *dev, int ioaddr);
static int el_open(struct net_device *dev);
static void el_timeout(struct net_device *dev);
......
......@@ -1293,42 +1293,6 @@ static void elp_set_mc_list(struct net_device *dev)
}
}
/******************************************************
*
* initialise Etherlink Plus board
*
******************************************************/
static inline void elp_init(struct net_device *dev)
{
elp_device *adapter = dev->priv;
/*
* set ptrs to various functions
*/
dev->open = elp_open; /* local */
dev->stop = elp_close; /* local */
dev->get_stats = elp_get_stats; /* local */
dev->hard_start_xmit = elp_start_xmit; /* local */
dev->tx_timeout = elp_timeout; /* local */
dev->watchdog_timeo = 10*HZ;
dev->set_multicast_list = elp_set_mc_list; /* local */
dev->ethtool_ops = &netdev_ethtool_ops; /* local */
/* Setup the generic properties */
ether_setup(dev);
/*
* setup ptr to adapter specific information
*/
memset(&(adapter->stats), 0, sizeof(struct net_device_stats));
/*
* memory information
*/
dev->mem_start = dev->mem_end = 0;
}
/************************************************************
*
* A couple of tests to see if there's 3C505 or not
......@@ -1442,12 +1406,13 @@ static int __init elp_autodetect(struct net_device *dev)
* work at all if it was in a weird state).
*/
int __init elplus_probe(struct net_device *dev)
static int __init elplus_setup(struct net_device *dev)
{
elp_device *adapter;
elp_device *adapter = dev->priv;
int i, tries, tries1, okay;
unsigned long timeout;
unsigned long cookie = 0;
int err = -ENODEV;
SET_MODULE_OWNER(dev);
......@@ -1456,17 +1421,8 @@ int __init elplus_probe(struct net_device *dev)
*/
dev->base_addr = elp_autodetect(dev);
if (!(dev->base_addr))
return -ENODEV;
/*
* setup ptr to adapter specific information
*/
adapter = (elp_device *) (dev->priv = kmalloc(sizeof(elp_device), GFP_KERNEL));
if (adapter == NULL) {
printk(KERN_ERR "%s: out of memory\n", dev->name);
if (!dev->base_addr)
return -ENODEV;
}
adapter->send_pcb_semaphore = 0;
......@@ -1544,8 +1500,7 @@ int __init elplus_probe(struct net_device *dev)
outb_control(adapter->hcr_val & ~(FLSH | ATTN), dev);
}
printk(KERN_ERR "%s: failed to initialise 3c505\n", dev->name);
release_region(dev->base_addr, ELP_IO_EXTENT);
return -ENODEV;
goto out;
okay:
if (dev->irq) { /* Is there a preset IRQ? */
......@@ -1560,14 +1515,14 @@ int __init elplus_probe(struct net_device *dev)
case 0:
printk(KERN_ERR "%s: IRQ probe failed: check 3c505 jumpers.\n",
dev->name);
return -ENODEV;
goto out;
case 1:
case 6:
case 8:
case 13:
printk(KERN_ERR "%s: Impossible IRQ %d reported by probe_irq_off().\n",
dev->name, dev->irq);
return -ENODEV;
goto out;
}
/*
* Now we have the IRQ number so we can disable the interrupts from
......@@ -1636,16 +1591,48 @@ int __init elplus_probe(struct net_device *dev)
printk(KERN_ERR "%s: adapter configuration failed\n", dev->name);
}
/*
* initialise the device
*/
elp_init(dev);
dev->open = elp_open; /* local */
dev->stop = elp_close; /* local */
dev->get_stats = elp_get_stats; /* local */
dev->hard_start_xmit = elp_start_xmit; /* local */
dev->tx_timeout = elp_timeout; /* local */
dev->watchdog_timeo = 10*HZ;
dev->set_multicast_list = elp_set_mc_list; /* local */
dev->ethtool_ops = &netdev_ethtool_ops; /* local */
memset(&(adapter->stats), 0, sizeof(struct net_device_stats));
dev->mem_start = dev->mem_end = 0;
err = register_netdev(dev);
if (err)
goto out;
return 0;
out:
release_region(dev->base_addr, ELP_IO_EXTENT);
return err;
}
struct net_device * __init elplus_probe(int unit)
{
struct net_device *dev = alloc_etherdev(sizeof(elp_device));
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
err = elplus_setup(dev);
if (err) {
free_netdev(dev);
return ERR_PTR(err);
}
return dev;
}
#ifdef MODULE
static struct net_device dev_3c505[ELP_MAX_CARDS];
static struct net_device *dev_3c505[ELP_MAX_CARDS];
static int io[ELP_MAX_CARDS];
static int irq[ELP_MAX_CARDS];
static int dma[ELP_MAX_CARDS];
......@@ -1661,10 +1648,12 @@ int init_module(void)
int this_dev, found = 0;
for (this_dev = 0; this_dev < ELP_MAX_CARDS; this_dev++) {
struct net_device *dev = &dev_3c505[this_dev];
struct net_device *dev = alloc_etherdev(sizeof(elp_device));
if (!dev)
break;
dev->irq = irq[this_dev];
dev->base_addr = io[this_dev];
dev->init = elplus_probe;
if (dma[this_dev]) {
dev->dma = dma[this_dev];
} else {
......@@ -1672,16 +1661,22 @@ int init_module(void)
printk(KERN_WARNING "3c505.c: warning, using default DMA channel,\n");
}
if (io[this_dev] == 0) {
if (this_dev) break;
if (this_dev) {
free_netdev(dev);
break;
}
printk(KERN_NOTICE "3c505.c: module autoprobe not recommended, give io=xx.\n");
}
if (register_netdev(dev) != 0) {
if (elplus_setup(dev) != 0) {
printk(KERN_WARNING "3c505.c: Failed to register card at 0x%x.\n", io[this_dev]);
if (found != 0) return 0;
return -ENXIO;
free_netdev(dev);
break;
}
dev_3c505[this_dev] = dev;
found++;
}
if (!found)
return -ENODEV;
return 0;
}
......@@ -1690,12 +1685,11 @@ void cleanup_module(void)
int this_dev;
for (this_dev = 0; this_dev < ELP_MAX_CARDS; this_dev++) {
struct net_device *dev = &dev_3c505[this_dev];
if (dev->priv != NULL) {
struct net_device *dev = dev_3c505[this_dev];
if (dev) {
unregister_netdev(dev);
kfree(dev->priv);
dev->priv = NULL;
release_region(dev->base_addr, ELP_IO_EXTENT);
free_netdev(dev);
}
}
}
......
......@@ -74,10 +74,6 @@ static unsigned int net_debug = NET_DEBUG;
#define debug net_debug
/* A zero-terminated list of common I/O addresses to be probed. */
static unsigned int netcard_portlist[] __initdata =
{ 0x300, 0x320, 0x340, 0x280, 0};
/*
Details of the i82586.
......@@ -286,8 +282,6 @@ static unsigned short init_words[] = {
/* Index to functions, as function prototypes. */
extern int el16_probe(struct net_device *dev); /* Called from Space.c */
static int el16_probe1(struct net_device *dev, int ioaddr);
static int el16_open(struct net_device *dev);
static int el16_send_packet(struct sk_buff *skb, struct net_device *dev);
......@@ -301,6 +295,10 @@ static void hardware_send_packet(struct net_device *dev, void *buf, short length
static void init_82586_mem(struct net_device *dev);
static struct ethtool_ops netdev_ethtool_ops;
static int io = 0x300;
static int irq;
static int mem_start;
/* Check for a network adaptor of this type, and return '0' iff one exists.
If dev->base_addr == 0, probe all likely locations.
......@@ -309,23 +307,50 @@ static struct ethtool_ops netdev_ethtool_ops;
device and return success.
*/
int __init el16_probe(struct net_device *dev)
struct net_device * __init el16_probe(int unit)
{
int base_addr = dev->base_addr;
int i;
struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
static unsigned ports[] = { 0x300, 0x320, 0x340, 0x280, 0};
unsigned *port;
int err = -ENODEV;
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;
mem_start = dev->mem_start & 15;
}
SET_MODULE_OWNER(dev);
if (base_addr > 0x1ff) /* Check a single specified location. */
return el16_probe1(dev, base_addr);
else if (base_addr != 0)
return -ENXIO; /* Don't probe at all. */
for (i = 0; netcard_portlist[i]; i++)
if (el16_probe1(dev, netcard_portlist[i]) == 0)
return 0;
if (io > 0x1ff) /* Check a single specified location. */
err = el16_probe1(dev, io);
else if (io != 0)
err = -ENXIO; /* Don't probe at all. */
else {
for (port = ports; *port; port++) {
err = el16_probe1(dev, *port);
if (!err)
break;
}
}
return -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, EL16_IO_EXTENT);
out:
free_netdev(dev);
return ERR_PTR(err);
}
static int __init el16_probe1(struct net_device *dev, int ioaddr)
......@@ -383,8 +408,8 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
printk(" %02x", dev->dev_addr[i]);
}
if ((dev->mem_start & 0xf) > 0)
net_debug = dev->mem_start & 7;
if (mem_start)
net_debug = mem_start & 7;
#ifdef MEM_BASE
dev->mem_start = MEM_BASE;
......@@ -416,27 +441,18 @@ static int __init el16_probe1(struct net_device *dev, int ioaddr)
if (net_debug)
printk(version);
/* Initialize the device structure. */
lp = dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev->priv == NULL) {
retval = -ENOMEM;
goto out;
}
memset(dev->priv, 0, sizeof(struct net_local));
lp = dev->priv;
memset(lp, 0, sizeof(*lp));
spin_lock_init(&lp->lock);
dev->open = el16_open;
dev->stop = el16_close;
dev->open = el16_open;
dev->stop = el16_close;
dev->hard_start_xmit = el16_send_packet;
dev->get_stats = el16_get_stats;
dev->tx_timeout = el16_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
dev->ethtool_ops = &netdev_ethtool_ops;
ether_setup(dev); /* Generic ethernet behaviour */
dev->flags&=~IFF_MULTICAST; /* Multicast doesn't work */
dev->flags &= ~IFF_MULTICAST; /* Multicast doesn't work */
return 0;
out:
release_region(ioaddr, EL16_IO_EXTENT);
......@@ -899,9 +915,7 @@ static struct ethtool_ops netdev_ethtool_ops = {
};
#ifdef MODULE
static struct net_device dev_3c507;
static int io = 0x300;
static int irq;
static struct net_device *dev_3c507;
MODULE_PARM(io, "i");
MODULE_PARM(irq, "i");
MODULE_PARM_DESC(io, "EtherLink16 I/O base address");
......@@ -911,26 +925,18 @@ int init_module(void)
{
if (io == 0)
printk("3c507: You should not use auto-probing with insmod!\n");
dev_3c507.base_addr = io;
dev_3c507.irq = irq;
dev_3c507.init = el16_probe;
if (register_netdev(&dev_3c507) != 0) {
printk("3c507: register_netdev() returned non-zero.\n");
return -EIO;
}
return 0;
dev_3c507 = el16_probe(-1);
return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0;
}
void
cleanup_module(void)
{
unregister_netdev(&dev_3c507);
kfree(dev_3c507.priv);
dev_3c507.priv = NULL;
/* If we don't do this, we can't re-insmod it later. */
free_irq(dev_3c507.irq, &dev_3c507);
release_region(dev_3c507.base_addr, EL16_IO_EXTENT);
struct net_device *dev = dev_3c507;
unregister_netdev(dev);
free_irq(dev->irq, dev);
release_region(dev->base_addr, EL16_IO_EXTENT);
free_netdev(dev);
}
#endif /* MODULE */
MODULE_LICENSE("GPL");
......
......@@ -569,14 +569,13 @@ static struct net_device *corkscrew_found_device(struct net_device *dev,
#ifdef MODULE
/* Allocate and fill new device structure. */
int dev_size = sizeof(struct net_device) + sizeof(struct corkscrew_private) + 15; /* Pad for alignment */
int dev_size = sizeof(struct corkscrew_private);
dev = (struct net_device *) kmalloc(dev_size, GFP_KERNEL);
dev = alloc_etherdev(dev_size);
if (!dev)
return NULL;
goto err_out;
memset(dev, 0, dev_size);
/* Align the Rx and Tx ring entries. */
dev->priv = (void *) (((long) dev + sizeof(struct net_device) + 15) & ~15);
vp = (struct corkscrew_private *) dev->priv;
dev->base_addr = ioaddr;
dev->irq = irq;
......@@ -593,19 +592,16 @@ static struct net_device *corkscrew_found_device(struct net_device *dev,
vp->full_duplex = 0;
vp->bus_master = 0;
}
ether_setup(dev);
vp->next_module = root_corkscrew_dev;
root_corkscrew_dev = dev;
SET_MODULE_OWNER(dev);
if (register_netdev(dev) != 0) {
kfree(dev);
return NULL;
}
if (register_netdev(dev) < 0)
goto err_free_dev;
#else /* not a MODULE */
/* Caution: quad-word alignment required for rings! */
dev->priv = kmalloc(sizeof(struct corkscrew_private), GFP_KERNEL);
if (!dev->priv)
return NULL;
goto err_out;
memset(dev->priv, 0, sizeof(struct corkscrew_private));
dev = init_etherdev(dev, sizeof(struct corkscrew_private));
dev->base_addr = ioaddr;
......@@ -627,6 +623,11 @@ static struct net_device *corkscrew_found_device(struct net_device *dev,
corkscrew_probe1(dev);
#endif /* MODULE */
return dev;
err_free_dev:
free_netdev(dev);
err_out:
return NULL;
}
static int corkscrew_probe1(struct net_device *dev)
......
......@@ -1129,21 +1129,40 @@ static void print_eth(unsigned char *add, char *str)
printk(" %02X%02X, %s\n", add[12], add[13], str);
}
int __init i82596_probe(struct net_device *dev)
static int io = 0x300;
static int irq = 10;
struct net_device * __init i82596_probe(int unit)
{
struct net_device *dev;
int i;
struct i596_private *lp;
char eth_addr[8];
static int probed;
int err;
if (probed)
return -ENODEV;
return ERR_PTR(-ENODEV);
probed++;
dev = alloc_etherdev(0);
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
} else {
dev->base_addr = io;
dev->irq = irq;
}
#ifdef ENABLE_MVME16x_NET
if (MACH_IS_MVME16x) {
if (mvme16x_config & MVME16x_CONFIG_NO_ETHERNET) {
printk(KERN_NOTICE "Ethernet probe disabled - chip not present\n");
return -ENODEV;
err = -ENODEV;
goto out;
}
memcpy(eth_addr, (void *) 0xfffc1f2c, 6); /* YUCK! Get addr from NOVRAM */
dev->base_addr = MVME_I596_BASE;
......@@ -1174,7 +1193,8 @@ int __init i82596_probe(struct net_device *dev)
if (!request_region(ioaddr, I596_TOTAL_SIZE, dev->name)) {
printk(KERN_ERR "82596: IO address 0x%04x in use\n", ioaddr);
return -EBUSY;
err = -EBUSY;
goto out;
}
for (i = 0; i < 8; i++) {
......@@ -1190,8 +1210,8 @@ int __init i82596_probe(struct net_device *dev)
if ((checksum % 0x100) ||
(memcmp(eth_addr, "\x00\x00\x49", 3) != 0)) {
release_region(ioaddr, I596_TOTAL_SIZE);
return -ENODEV;
err = -ENODEV;
goto out1;
}
dev->base_addr = ioaddr;
......@@ -1200,13 +1220,10 @@ int __init i82596_probe(struct net_device *dev)
#endif
dev->mem_start = (int)__get_free_pages(GFP_ATOMIC, 0);
if (!dev->mem_start) {
#ifdef ENABLE_APRICOT
release_region(dev->base_addr, I596_TOTAL_SIZE);
#endif
return -ENOMEM;
err = -ENOMEM;
goto out1;
}
ether_setup(dev);
DEB(DEB_PROBE,printk(KERN_INFO "%s: 82596 at %#3lx,", dev->name, dev->base_addr));
for (i = 0; i < 6; i++)
......@@ -1244,7 +1261,26 @@ int __init i82596_probe(struct net_device *dev)
lp->scb.rfd = I596_NULL;
lp->lock = SPIN_LOCK_UNLOCKED;
return 0;
err = register_netdev(dev);
if (err)
goto out2;
return dev;
out2:
#ifdef __mc68000__
/* XXX This assumes default cache mode to be IOMAP_FULL_CACHING,
* XXX which may be invalid (CONFIG_060_WRITETHROUGH)
*/
kernel_set_cachemode((void *)(dev->mem_start), 4096,
IOMAP_FULL_CACHING);
#endif
free_page ((u32)(dev->mem_start));
out1:
#ifdef ENABLE_APRICOT
release_region(dev->base_addr, I596_TOTAL_SIZE);
#endif
out:
free_netdev(dev);
return ERR_PTR(err);
}
static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
......@@ -1532,11 +1568,9 @@ static void set_multicast_list(struct net_device *dev)
}
#ifdef MODULE
static struct net_device dev_82596 = { .init = i82596_probe };
static struct net_device *dev_82596;
#ifdef ENABLE_APRICOT
static int io = 0x300;
static int irq = 10;
MODULE_PARM(irq, "i");
MODULE_PARM_DESC(irq, "Apricot IRQ number");
#endif
......@@ -1547,34 +1581,31 @@ static int debug = -1;
int init_module(void)
{
#ifdef ENABLE_APRICOT
dev_82596.base_addr = io;
dev_82596.irq = irq;
#endif
if (debug >= 0)
i596_debug = debug;
if (register_netdev(&dev_82596) != 0)
return -EIO;
dev_82596 = i82596_probe(-1);
if (IS_ERR(dev_82596))
return PTR_ERR(dev_82596);
return 0;
}
void cleanup_module(void)
{
unregister_netdev(&dev_82596);
unregister_netdev(dev_82596);
#ifdef __mc68000__
/* XXX This assumes default cache mode to be IOMAP_FULL_CACHING,
* XXX which may be invalid (CONFIG_060_WRITETHROUGH)
*/
kernel_set_cachemode((void *)(dev_82596.mem_start), 4096,
kernel_set_cachemode((void *)(dev_82596->mem_start), 4096,
IOMAP_FULL_CACHING);
#endif
free_page ((u32)(dev_82596.mem_start));
dev_82596.priv = NULL;
free_page ((u32)(dev_82596->mem_start));
#ifdef ENABLE_APRICOT
/* If we don't do this, we can't re-insmod it later. */
release_region(dev_82596.base_addr, I596_TOTAL_SIZE);
release_region(dev_82596->base_addr, I596_TOTAL_SIZE);
#endif
free_netdev(dev_82596);
}
#endif /* MODULE */
......
......@@ -55,24 +55,24 @@ 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 int i82596_probe(struct net_device *);
extern struct net_device *i82596_probe(int unit);
extern int ewrk3_probe(struct net_device *);
extern int el1_probe(struct net_device *);
extern int wavelan_probe(struct net_device *);
extern int arlan_probe(struct net_device *);
extern int el16_probe(struct net_device *);
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 int elplus_probe(struct net_device *);
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 int ni5010_probe(struct net_device *);
extern int ni52_probe(struct net_device *);
extern int ni65_probe(struct net_device *);
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 int SK_init(struct net_device *);
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 *);
......@@ -96,7 +96,7 @@ extern struct net_device *cops_probe(int unit);
extern struct net_device *ltpc_probe(void);
/* Detachable devices ("pocket adaptors") */
extern int de620_probe(struct net_device *);
extern struct net_device *de620_probe(int unit);
/* Fibre Channel adapters */
extern int iph5526_probe(struct net_device *dev);
......@@ -110,6 +110,11 @@ struct devprobe
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
......@@ -135,6 +140,21 @@ static int __init probe_list(struct net_device *dev, struct devprobe *plist)
return -ENODEV;
}
static int __init probe_list2(int unit, struct devprobe2 *p, int autoprobe)
{
struct net_device *dev;
for (; p->probe; p++) {
if (autoprobe && p->status)
continue;
dev = p->probe(unit);
if (!IS_ERR(dev))
return 0;
if (autoprobe)
p->status = PTR_ERR(dev);
}
return -ENODEV;
}
/*
* This is a bit of an artificial separation as there are PCI drivers
* that also probe for EISA cards (in the PCI group) and there are ISA
......@@ -239,6 +259,10 @@ 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
......@@ -272,7 +296,7 @@ static struct devprobe isa_probes[] __initdata = {
{NULL, 0},
};
static struct devprobe parport_probes[] __initdata = {
static struct devprobe2 parport_probes[] __initdata = {
#ifdef CONFIG_DE620 /* D-Link DE-620 adapter */
{de620_probe, 0},
#endif
......@@ -363,8 +387,7 @@ static int __init ethif_probe(int unit)
probe_list(dev, mips_probes) == 0 ||
probe_list(dev, eisa_probes) == 0 ||
probe_list(dev, mca_probes) == 0 ||
probe_list(dev, isa_probes) == 0 ||
probe_list(dev, parport_probes) == 0)
probe_list(dev, isa_probes) == 0)
err = register_netdev(dev);
if (err)
......@@ -372,13 +395,37 @@ static int __init ethif_probe(int unit)
return err;
}
static void __init ethif_probe2(int unit)
{
unsigned long base_addr = netdev_boot_base("eth", unit);
if (base_addr == 1)
return;
probe_list2(unit, isa_probes2, base_addr == 0) &&
probe_list2(unit, parport_probes, base_addr == 0);
}
#ifdef CONFIG_TR
/* Token-ring device probe */
extern int ibmtr_probe(struct net_device *);
extern int sk_isa_probe(struct net_device *);
extern int proteon_probe(struct net_device *);
extern int smctr_probe(struct net_device *);
extern struct net_device *sk_isa_probe(int unit);
extern struct net_device *proteon_probe(int unit);
extern struct net_device *smctr_probe(int unit);
static struct devprobe2 tr_probes2[] __initdata = {
#ifdef CONFIG_SKISA
{sk_isa_probe, 0},
#endif
#ifdef CONFIG_PROTEON
{proteon_probe, 0},
#endif
#ifdef CONFIG_SMCTR
{smctr_probe, 0},
#endif
{NULL, 0},
};
static __init int trif_probe(int unit)
{
......@@ -394,15 +441,6 @@ static __init int trif_probe(int unit)
if (
#ifdef CONFIG_IBMTR
ibmtr_probe(dev) == 0 ||
#endif
#ifdef CONFIG_SKISA
sk_isa_probe(dev) == 0 ||
#endif
#ifdef CONFIG_PROTEON
proteon_probe(dev) == 0 ||
#endif
#ifdef CONFIG_SMCTR
smctr_probe(dev) == 0 ||
#endif
0 )
err = register_netdev(dev);
......@@ -412,6 +450,15 @@ static __init int trif_probe(int unit)
return err;
}
static void __init trif_probe2(int unit)
{
unsigned long base_addr = netdev_boot_base("tr", unit);
if (base_addr == 1)
return;
probe_list2(unit, tr_probes2, base_addr == 0);
}
#endif
......@@ -437,10 +484,12 @@ static int __init net_olddevs_init(void)
#endif
#ifdef CONFIG_TR
for (num = 0; num < 8; ++num)
trif_probe(num);
if (!trif_probe(num))
trif_probe2(num);
#endif
for (num = 0; num < 8; ++num)
ethif_probe(num);
if (!ethif_probe(num))
ethif_probe2(num);
#ifdef CONFIG_COPS
cops_probe(0);
......
......@@ -226,7 +226,6 @@ static int de620_rx_intr(struct net_device *);
/* Initialization */
static int adapter_init(struct net_device *);
int de620_probe(struct net_device *);
static int read_eeprom(struct net_device *);
......@@ -814,11 +813,16 @@ static int adapter_init(struct net_device *dev)
*
* Check if there is a DE-620 connected
*/
int __init de620_probe(struct net_device *dev)
struct net_device * __init de620_probe(int unit)
{
static struct net_device_stats de620_netstats;
int i;
byte checkbyte = 0xa5;
struct net_device *dev;
int err = -ENOMEM;
int i;
dev = alloc_etherdev(sizeof(struct net_device_stats));
if (!dev)
goto out;
SET_MODULE_OWNER(dev);
......@@ -831,11 +835,23 @@ int __init de620_probe(struct net_device *dev)
dev->base_addr = io;
dev->irq = irq;
/* allow overriding parameters on command line */
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
}
if (de620_debug)
printk(version);
printk(KERN_INFO "D-Link DE-620 pocket adapter");
if (!request_region(dev->base_addr, 3, "de620")) {
printk(" io 0x%3lX, which is busy.\n", dev->base_addr);
err = -EBUSY;
goto out1;
}
/* Initially, configure basic nibble mode, so we can read the EEPROM */
NIC_Cmd = DEF_NIC_CMD;
de620_set_register(dev, W_EIP, EIPRegister);
......@@ -846,12 +862,8 @@ int __init de620_probe(struct net_device *dev)
if ((checkbyte != 0xa5) || (read_eeprom(dev) != 0)) {
printk(" not identified in the printer port\n");
return -ENODEV;
}
if (!request_region(dev->base_addr, 3, "de620")) {
printk(KERN_ERR "io 0x%3lX, which is busy.\n", dev->base_addr);
return -EBUSY;
err = -ENODEV;
goto out2;
}
/* else, got it! */
......@@ -870,10 +882,6 @@ int __init de620_probe(struct net_device *dev)
else
printk(" UTP)\n");
/* Initialize the device structure. */
dev->priv = &de620_netstats;
memset(dev->priv, 0, sizeof(struct net_device_stats));
dev->get_stats = get_stats;
dev->open = de620_open;
dev->stop = de620_close;
......@@ -884,8 +892,6 @@ int __init de620_probe(struct net_device *dev)
/* base_addr and irq are already set, see above! */
ether_setup(dev);
/* dump eeprom */
if (de620_debug) {
printk("\nEEPROM contents:\n");
......@@ -899,7 +905,17 @@ int __init de620_probe(struct net_device *dev)
printk("SCR = 0x%02x\n", nic_data.SCR);
}
return 0;
err = register_netdev(dev);
if (err)
goto out2;
return dev;
out2:
release_region(dev->base_addr, 3);
out1:
free_netdev(dev);
out:
return ERR_PTR(err);
}
/**********************************
......@@ -994,20 +1010,21 @@ static int __init read_eeprom(struct net_device *dev)
*
*/
#ifdef MODULE
static struct net_device de620_dev;
static struct net_device *de620_dev;
int init_module(void)
{
de620_dev.init = de620_probe;
if (register_netdev(&de620_dev) != 0)
return -EIO;
de620_dev = de620_probe(-1);
if (IS_ERR(de620_dev))
return PTR_ERR(de620_dev);
return 0;
}
void cleanup_module(void)
{
unregister_netdev(&de620_dev);
release_region(de620_dev.base_addr, 3);
unregister_netdev(de620_dev);
release_region(de620_dev->base_addr, 3);
free_netdev(de620_dev);
}
#endif /* MODULE */
MODULE_LICENSE("GPL");
......
......@@ -491,7 +491,7 @@ static int __devinit dfx_init_one_pci_or_eisa(struct pci_dev *pdev, long ioaddr)
err_out_region:
release_region(ioaddr, pdev ? PFI_K_CSR_IO_LEN : PI_ESIC_K_CSR_IO_LEN);
err_out:
kfree(dev);
free_netdev(dev);
return err;
}
......
......@@ -103,7 +103,7 @@ static int __init dummy_init_one(int index)
return -ENOMEM;
if ((err = register_netdev(dev_dummy))) {
kfree(dev_dummy);
free_netdev(dev_dummy);
dev_dummy = NULL;
} else {
dummies[index] = dev_dummy;
......
......@@ -600,7 +600,7 @@ static int __init eql_init_module(void)
err = register_netdev(dev_eql);
if (err)
kfree(dev_eql);
free_netdev(dev_eql);
return err;
}
......
This diff is collapsed.
......@@ -354,50 +354,76 @@ static void alloc586(struct net_device *dev)
memset((char *)p->scb,0,sizeof(struct scb_struct));
}
/* set: io,irq,memstart,memend or set it when calling insmod */
static int irq=9;
static int io=0x300;
static long memstart; /* e.g 0xd0000 */
static long memend; /* e.g 0xd4000 */
/**********************************************
* probe the ni5210-card
*/
int __init ni52_probe(struct net_device *dev)
struct net_device * __init ni52_probe(int unit)
{
#ifndef MODULE
int *port;
struct net_device *dev = alloc_etherdev(sizeof(struct priv));
static int ports[] = {0x300, 0x280, 0x360 , 0x320 , 0x340, 0};
#endif
int base_addr = dev->base_addr;
int *port;
int err = 0;
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
io = dev->base_addr;
irq = dev->irq;
memstart = dev->mem_start;
memend = dev->mem_end;
}
SET_MODULE_OWNER(dev);
if (base_addr > 0x1ff) /* Check a single specified location. */
return ni52_probe1(dev, base_addr);
else if (base_addr > 0) /* Don't probe at all. */
return -ENXIO;
#ifdef MODULE
printk("%s: no autoprobing allowed for modules.\n",dev->name);
#else
for (port = ports; *port; port++) {
int ioaddr = *port;
dev->base_addr = ioaddr;
if (ni52_probe1(dev, ioaddr) == 0)
return 0;
}
if (io > 0x1ff) { /* Check a single specified location. */
err = ni52_probe1(dev, io);
} else if (io > 0) { /* Don't probe at all. */
err = -ENXIO;
} else {
for (port = ports; *port && ni52_probe1(dev, *port) ; port++)
;
if (*port)
goto got_it;
#ifdef FULL_IO_PROBE
for(dev->base_addr=0x200; dev->base_addr<0x400; dev->base_addr+=8)
if (ni52_probe1(dev, dev->base_addr) == 0)
return 0;
#endif
for (io = 0x200; io < 0x400 && ni52_probe1(dev, io); io += 8)
;
if (io < 0x400)
goto got_it;
#endif
dev->base_addr = base_addr;
return -ENODEV;
err = -ENODEV;
}
if (err)
goto out;
got_it:
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
release_region(dev->base_addr, NI52_TOTAL_SIZE);
out:
free_netdev(dev);
return ERR_PTR(err);
}
static int __init ni52_probe1(struct net_device *dev,int ioaddr)
{
int i, size, retval;
dev->base_addr = ioaddr;
dev->irq = irq;
dev->mem_start = memstart;
dev->mem_end = memend;
if (!request_region(ioaddr, NI52_TOTAL_SIZE, dev->name))
return -EBUSY;
......@@ -416,7 +442,7 @@ static int __init ni52_probe1(struct net_device *dev,int ioaddr)
goto out;
}
printk("%s: NI5210 found at %#3lx, ",dev->name,dev->base_addr);
printk(KERN_INFO "%s: NI5210 found at %#3lx, ",dev->name,dev->base_addr);
/*
* check (or search) IO-Memory, 8K and 16K
......@@ -469,13 +495,6 @@ static int __init ni52_probe1(struct net_device *dev,int ioaddr)
dev->mem_end = dev->mem_start + size; /* set mem_end showed by 'ifconfig' */
#endif
dev->priv = (void *) kmalloc(sizeof(struct priv),GFP_KERNEL);
if(dev->priv == NULL) {
printk("%s: Ooops .. can't allocate private driver memory.\n",dev->name);
retval = -ENOMEM;
goto out;
}
/* warning: we don't free it on errors */
memset((char *) dev->priv,0,sizeof(struct priv));
((struct priv *) (dev->priv))->memtop = isa_bus_to_virt(dev->mem_start) + size;
......@@ -503,8 +522,6 @@ static int __init ni52_probe1(struct net_device *dev,int ioaddr)
if(!dev->irq)
{
printk("?autoirq, Failed to detect IRQ line!\n");
kfree(dev->priv);
dev->priv = NULL;
retval = -EAGAIN;
goto out;
}
......@@ -526,8 +543,6 @@ static int __init ni52_probe1(struct net_device *dev,int ioaddr)
dev->if_port = 0;
ether_setup(dev);
return 0;
out:
release_region(ioaddr, NI52_TOTAL_SIZE);
......@@ -1295,13 +1310,7 @@ static void set_multicast_list(struct net_device *dev)
}
#ifdef MODULE
static struct net_device dev_ni52;
/* set: io,irq,memstart,memend or set it when calling insmod */
static int irq=9;
static int io=0x300;
static long memstart; /* e.g 0xd0000 */
static long memend; /* e.g 0xd4000 */
static struct net_device *dev_ni52;
MODULE_PARM(io, "i");
MODULE_PARM(irq, "i");
......@@ -1318,22 +1327,17 @@ int init_module(void)
printk("ni52: Autoprobing not allowed for modules.\nni52: Set symbols 'io' 'irq' 'memstart' and 'memend'\n");
return -ENODEV;
}
dev_ni52.init = ni52_probe;
dev_ni52.irq = irq;
dev_ni52.base_addr = io;
dev_ni52.mem_end = memend;
dev_ni52.mem_start = memstart;
if (register_netdev(&dev_ni52) != 0)
return -EIO;
dev_ni52 = ni52_probe(-1);
if (IS_ERR(dev_ni52))
return PTR_ERR(dev_ni52);
return 0;
}
void cleanup_module(void)
{
release_region(dev_ni52.base_addr, NI52_TOTAL_SIZE);
unregister_netdev(&dev_ni52);
kfree(dev_ni52.priv);
dev_ni52.priv = NULL;
unregister_netdev(dev_ni52);
release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE);
free_netdev(dev_ni52);
}
#endif /* MODULE */
......
......@@ -343,29 +343,64 @@ static int ni65_close(struct net_device *dev)
return 0;
}
static void cleanup_card(struct net_device *dev)
{
struct priv *p = (struct priv *) dev->priv;
disable_dma(dev->dma);
free_dma(dev->dma);
release_region(dev->base_addr, cards[p->cardno].total_size);
ni65_free_buffer(p);
}
/* set: io,irq,dma or set it when calling insmod */
static int irq;
static int io;
static int dma;
/*
* Probe The Card (not the lance-chip)
*/
#ifdef MODULE
static
#endif
int __init ni65_probe(struct net_device *dev)
struct net_device * __init ni65_probe(int unit)
{
int *port;
struct net_device *dev = alloc_etherdev(0);
static int ports[] = {0x360,0x300,0x320,0x340, 0};
if (dev->base_addr > 0x1ff) /* Check a single specified location. */
return ni65_probe1(dev, dev->base_addr);
else if (dev->base_addr > 0) /* Don't probe at all. */
return -ENXIO;
for (port = ports; *port; port++)
{
if (ni65_probe1(dev, *port) == 0)
return 0;
int *port;
int err = 0;
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
irq = dev->irq;
dma = dev->dma;
} else {
dev->base_addr = io;
}
return -ENODEV;
if (dev->base_addr > 0x1ff) { /* Check a single specified location. */
err = ni65_probe1(dev, dev->base_addr);
} else if (dev->base_addr > 0) { /* Don't probe at all. */
err = -ENXIO;
} else {
for (port = ports; *port && ni65_probe1(dev, *port); port++)
;
if (!*port)
err = -ENODEV;
}
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
cleanup_card(dev);
out:
free_netdev(dev);
return ERR_PTR(err);
}
/*
......@@ -377,6 +412,9 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
struct priv *p;
unsigned long flags;
dev->irq = irq;
dev->dma = dma;
for(i=0;i<NUM_CARDS;i++) {
if(!request_region(ioaddr, cards[i].total_size, cards[i].cardname))
continue;
......@@ -521,9 +559,6 @@ static int __init ni65_probe1(struct net_device *dev,int ioaddr)
dev->watchdog_timeo = HZ/2;
dev->get_stats = ni65_get_stats;
dev->set_multicast_list = set_multicast_list;
ether_setup(dev);
return 0; /* everything is OK */
}
......@@ -1213,12 +1248,7 @@ static void set_multicast_list(struct net_device *dev)
}
#ifdef MODULE
static struct net_device dev_ni65 = { .base_addr = 0x360, .irq = 9, .init = ni65_probe };
/* set: io,irq,dma or set it when calling insmod */
static int irq;
static int io;
static int dma;
static struct net_device *dev_ni65;
MODULE_PARM(irq, "i");
MODULE_PARM(io, "i");
......@@ -1229,26 +1259,15 @@ MODULE_PARM_DESC(dma, "ni6510 ISA DMA channel (ignored for some cards)");
int init_module(void)
{
dev_ni65.irq = irq;
dev_ni65.dma = dma;
dev_ni65.base_addr = io;
if (register_netdev(&dev_ni65) != 0)
return -EIO;
return 0;
dev_ni65 = ni65_probe(-1);
return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0;
}
void cleanup_module(void)
{
struct priv *p;
p = (struct priv *) dev_ni65.priv;
if(!p)
BUG();
disable_dma(dev_ni65.dma);
free_dma(dev_ni65.dma);
unregister_netdev(&dev_ni65);
release_region(dev_ni65.base_addr,cards[p->cardno].total_size);
ni65_free_buffer(p);
dev_ni65.priv = NULL;
unregister_netdev(dev_ni65);
cleanup_card(dev_ni65);
free_netdev(dev_ni65);
}
#endif /* MODULE */
......
......@@ -2034,7 +2034,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
pci_free_consistent(pci_dev, 4 * DESC_SIZE * NR_RX_DESC, dev->rx_info.descs, dev->rx_info.phy_descs);
pci_disable_device(pci_dev);
out_free:
kfree(dev);
free_netdev(&dev->net_dev);
pci_set_drvdata(pci_dev, NULL);
out:
return err;
......
......@@ -1306,17 +1306,23 @@ static void plip_attach (struct parport *port)
if (!nl->pardev) {
printk(KERN_ERR "%s: parport_register failed\n", name);
kfree(dev);
goto err_free_dev;
return;
}
if (register_netdev(dev)) {
printk(KERN_ERR "%s: network register failed\n", name);
kfree(dev);
} else {
dev_plip[unit++] = dev;
goto err_parport_unregister;
}
dev_plip[unit++] = dev;
}
return;
err_parport_unregister:
parport_unregister_device(nl->pardev);
err_free_dev:
free_netdev(dev);
return;
}
/* plip_detach() is called (by the parport code) when a port is
......
......@@ -718,8 +718,10 @@ static int __init shaper_init(void)
if (!dev)
break;
if (register_netdev(dev))
if (register_netdev(dev)) {
free_netdev(dev);
break;
}
devs[i] = dev;
shapers_registered++;
......@@ -737,9 +739,12 @@ static void __exit shaper_exit (void)
{
int i;
for (i = 0; i < shapers_registered; i++)
if (devs[i])
for (i = 0; i < shapers_registered; i++) {
if (devs[i]) {
unregister_netdev(devs[i]);
free_netdev(devs[i]);
}
}
kfree(devs);
devs = NULL;
......
......@@ -457,8 +457,6 @@ struct priv
/* static variables */
static SK_RAM *board; /* pointer to our memory mapped board components */
static struct net_device *SK_dev;
unsigned long SK_ioaddr;
static spinlock_t SK_lock = SPIN_LOCK_UNLOCKED;
/* Macros */
......@@ -472,7 +470,6 @@ static spinlock_t SK_lock = SPIN_LOCK_UNLOCKED;
* See for short explanation of each function its definitions header.
*/
int SK_init(struct net_device *dev);
static int SK_probe(struct net_device *dev, short ioaddr);
static void SK_timeout(struct net_device *dev);
......@@ -530,84 +527,71 @@ void SK_print_ram(struct net_device *dev);
* YY/MM/DD uid Description
-*/
static int io; /* 0 == probe */
/*
* Check for a network adaptor of this type, and return '0' if one exists.
* If dev->base_addr == 0, probe all likely locations.
* If dev->base_addr == 1, always return failure.
*/
int __init SK_init(struct net_device *dev)
struct net_device * __init SK_init(int unit)
{
int ioaddr; /* I/O port address used for POS regs */
int *port, ports[] = SK_IO_PORTS; /* SK_G16 supported ports */
static unsigned version_printed;
struct net_device *dev = alloc_etherdev(sizeof(struct priv));
int err = -ENODEV;
if (!dev)
return ERR_PTR(-ENOMEM);
/* get preconfigured base_addr from dev which is done in Space.c */
int base_addr = dev->base_addr;
if (unit >= 0) {
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
io = dev->base_addr;
}
if (version_printed++ == 0)
PRINTK(("%s: %s", SK_NAME, rcsid));
if (base_addr > 0x0ff) /* Check a single specified address */
{
int rc = -ENODEV;
ioaddr = base_addr;
/* Check if on specified address is a SK_G16 */
if (!request_region(ioaddr, ETHERCARD_TOTAL_SIZE, "sk_g16"))
return -EBUSY;
if ( (inb(SK_POS0) == SK_IDLOW) ||
(inb(SK_POS1) == SK_IDHIGH) )
{
rc = SK_probe(dev, ioaddr);
}
if (rc)
release_region(ioaddr, ETHERCARD_TOTAL_SIZE);
return rc;
}
else if (base_addr > 0) /* Don't probe at all */
{
return -ENXIO;
if (io > 0xff) { /* Check a single specified address */
err = -EBUSY;
/* Check if on specified address is a SK_G16 */
if (request_region(io, ETHERCARD_TOTAL_SIZE, "sk_g16")) {
err = SK_probe(dev, io);
if (!err)
goto got_it;
release_region(io, ETHERCARD_TOTAL_SIZE);
}
} else if (io > 0) { /* Don't probe at all */
err = -ENXIO;
} else {
/* Autoprobe base_addr */
for (port = &ports[0]; *port; port++) {
io = *port;
/* Check if I/O Port region is used by another board */
if (!request_region(io, ETHERCARD_TOTAL_SIZE, "sk_g16"))
continue; /* Try next Port address */
/* Check if at ioaddr is a SK_G16 */
if (SK_probe(dev, io) == 0)
goto got_it;
release_region(io, ETHERCARD_TOTAL_SIZE);
}
}
/* Autoprobe base_addr */
for (port = &ports[0]; *port; port++)
{
ioaddr = *port; /* we need ioaddr for accessing POS regs */
/* Check if I/O Port region is used by another board */
if (!request_region(ioaddr, ETHERCARD_TOTAL_SIZE, "sk_g16"))
{
continue; /* Try next Port address */
}
/* Check if at ioaddr is a SK_G16 */
if ( !(inb(SK_POS0) == SK_IDLOW) ||
!(inb(SK_POS1) == SK_IDHIGH) )
{
release_region(ioaddr, ETHERCARD_TOTAL_SIZE);
continue; /* Try next Port address */
}
dev->base_addr = ioaddr; /* Set I/O Port Address */
if (SK_probe(dev, ioaddr) == 0)
{
return 0; /* Card found and initialized */
}
release_region(ioaddr, ETHERCARD_TOTAL_SIZE);
err_out:
free_netdev(dev);
return ERR_PTR(err);
got_it:
err = register_netdev(dev);
if (err) {
release_region(dev->base_addr, ETHERCARD_TOTAL_SIZE);
goto err_out;
}
dev->base_addr = base_addr; /* Write back original base_addr */
return -ENODEV; /* Failed to find or init driver */
return dev;
} /* End of SK_init */
......@@ -620,54 +604,25 @@ MODULE_PARM_DESC(io, "0 to probe common ports (unsafe), or the I/O base of the b
#ifdef MODULE
static int io; /* 0 == probe */
static struct net_device *SK_dev;
static int __init SK_init_module (void)
{
int rc;
SK_dev = init_etherdev (NULL, 0);
if (!SK_dev)
return -ENOMEM;
SK_dev->base_addr = io;
rc = SK_init (SK_dev);
if (rc) {
unregister_netdev (SK_dev);
kfree (SK_dev);
SK_dev = NULL;
}
return rc;
SK_dev = SK_init(-1);
return IS_ERR(SK_dev) ? PTR_ERR(SK_dev) : 0;
}
#endif /* MODULE */
static void __exit SK_cleanup_module (void)
{
if (SK_dev) {
if (SK_dev->priv) {
kfree(SK_dev->priv);
SK_dev->priv = NULL;
}
unregister_netdev(SK_dev);
free_netdev(SK_dev);
SK_dev = NULL;
}
if (SK_ioaddr) {
release_region(SK_ioaddr, ETHERCARD_TOTAL_SIZE);
SK_ioaddr = 0;
}
unregister_netdev(SK_dev);
release_region(SK_dev->base_addr, ETHERCARD_TOTAL_SIZE);
free_netdev(SK_dev);
}
#ifdef MODULE
module_init(SK_init_module);
#endif
module_exit(SK_cleanup_module);
#endif
/*-
......@@ -695,7 +650,11 @@ int __init SK_probe(struct net_device *dev, short ioaddr)
int sk_addr_flag = 0; /* SK ADDR correct? 1 - no, 0 - yes */
unsigned int rom_addr; /* used to store RAM address used for POS_ADDR */
struct priv *p; /* SK_G16 private structure */
struct priv *p = dev->priv; /* SK_G16 private structure */
if (inb(SK_POS0) != SK_IDLOW || inb(SK_POS1) != SK_IDHIGH)
return -ENODEV;
dev->base_addr = ioaddr;
if (SK_ADDR & 0x3fff || SK_ADDR < 0xa0000)
{
......@@ -837,12 +796,6 @@ int __init SK_probe(struct net_device *dev, short ioaddr)
dev->dev_addr[4],
dev->dev_addr[5]);
/* Allocate memory for private structure */
p = dev->priv = (void *) kmalloc(sizeof(struct priv), GFP_KERNEL);
if (p == NULL) {
printk("%s: ERROR - no memory for driver data!\n", dev->name);
return -ENOMEM;
}
memset((char *) dev->priv, 0, sizeof(struct priv)); /* clear memory */
/* Assign our Device Driver functions */
......@@ -856,10 +809,6 @@ int __init SK_probe(struct net_device *dev, short ioaddr)
dev->watchdog_timeo = HZ/7;
/* Set the generic fields of the device structure */
ether_setup(dev);
dev->flags &= ~IFF_MULTICAST;
/* Initialize private structure */
......@@ -884,12 +833,7 @@ int __init SK_probe(struct net_device *dev, short ioaddr)
SK_print_pos(dev, "End of SK_probe");
SK_print_ram(dev);
#endif
SK_dev = dev;
SK_ioaddr = ioaddr;
return 0; /* Initialization done */
} /* End of SK_probe() */
......@@ -1280,7 +1224,7 @@ static int SK_send_packet(struct sk_buff *skb, struct net_device *dev)
memcpy_toio((tmdp->u.buffer & 0x00ffffff), skb->data, skb->len);
if (len != skb->len)
memcpy_toio((tmdp->u.buffer & 0x00ffffff) + sb->len, pad, len-skb->len);
memcpy_toio((tmdp->u.buffer & 0x00ffffff) + skb->len, pad, len-skb->len);
writew(-len, &tmdp->blen); /* set length to transmit */
......
......@@ -63,7 +63,7 @@ static int dmalist[] __initdata = {
static char cardname[] = "Proteon 1392\0";
int proteon_probe(struct net_device *dev);
struct net_device *proteon_probe(int unit);
static int proteon_open(struct net_device *dev);
static int proteon_close(struct net_device *dev);
static void proteon_read_eeprom(struct net_device *dev);
......@@ -89,80 +89,69 @@ static void proteon_sifwritew(struct net_device *dev, unsigned short val, unsign
outw(val, dev->base_addr + reg);
}
struct proteon_card {
struct net_device *dev;
struct proteon_card *next;
};
static struct proteon_card *proteon_card_list;
static int __init proteon_probe1(int ioaddr)
static int __init proteon_probe1(struct net_device *dev, int ioaddr)
{
unsigned char chk1, chk2;
int i;
if (!request_region(ioaddr, PROTEON_IO_EXTENT, cardname))
return -ENODEV;
chk1 = inb(ioaddr + 0x1f); /* Get Proteon ID reg 1 */
if (chk1 != 0x1f)
return (-1);
if (chk1 != 0x1f)
goto nodev;
chk1 = inb(ioaddr + 0x1e) & 0x07; /* Get Proteon ID reg 0 */
for (i=0; i<16; i++) {
chk2 = inb(ioaddr + 0x1e) & 0x07;
if (((chk1 + 1) & 0x07) != chk2)
return (-1);
goto nodev;
chk1 = chk2;
}
dev->base_addr = ioaddr;
return (0);
nodev:
release_region(ioaddr, PROTEON_IO_EXTENT);
return -ENODEV;
}
int __init proteon_probe(struct net_device *dev)
struct net_device * __init proteon_probe(int unit)
{
static int versionprinted;
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
struct net_local *tp;
int i,j;
struct proteon_card *card;
static int versionprinted;
const unsigned *port;
int j,err = 0;
#ifndef MODULE
netdev_boot_setup_check(dev);
tr_setup(dev);
#endif
if (!dev)
return ERR_PTR(-ENOMEM);
SET_MODULE_OWNER(dev);
if (!dev->base_addr)
{
for(i = 0; portlist[i]; i++)
{
if (!request_region(portlist[i], PROTEON_IO_EXTENT, cardname))
continue;
if(proteon_probe1(portlist[i]))
{
release_region(dev->base_addr, PROTEON_IO_EXTENT);
continue;
}
if (unit >= 0) {
sprintf(dev->name, "tr%d", unit);
netdev_boot_setup_check(dev);
}
dev->base_addr = portlist[i];
break;
SET_MODULE_OWNER(dev);
if (dev->base_addr) /* probe specific location */
err = proteon_probe1(dev, dev->base_addr);
else {
for (port = portlist; *port; port++) {
err = proteon_probe1(dev, *port);
if (!err)
break;
}
if(!dev->base_addr)
return -1;
}
else
{
if (!request_region(dev->base_addr, PROTEON_IO_EXTENT, cardname))
return -1;
if(proteon_probe1(dev->base_addr))
{
release_region(dev->base_addr, PROTEON_IO_EXTENT);
return -1;
}
}
if (err)
goto out4;
/* At this point we have found a valid card. */
if (versionprinted++ == 0)
printk(KERN_DEBUG "%s", version);
err = -EIO;
if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL))
goto out4;
......@@ -264,14 +253,11 @@ int __init proteon_probe(struct net_device *dev)
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
dev->name, dev->base_addr, dev->irq, dev->dma);
/* Enlist in the card list */
card = kmalloc(sizeof(struct proteon_card), GFP_KERNEL);
if (!card)
err = register_netdev(dev);
if (err)
goto out;
card->next = proteon_card_list;
proteon_card_list = card;
card->dev = dev;
return 0;
return dev;
out:
free_dma(dev->dma);
out2:
......@@ -280,7 +266,8 @@ int __init proteon_probe(struct net_device *dev)
tmsdev_term(dev);
out4:
release_region(dev->base_addr, PROTEON_IO_EXTENT);
return -1;
free_netdev(dev);
return ERR_PTR(err);
}
/*
......@@ -370,50 +357,50 @@ MODULE_PARM(io, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
MODULE_PARM(irq, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
MODULE_PARM(dma, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
static int __init setup_card(unsigned long io, unsigned irq, unsigned char dma)
static struct net_device *proteon_dev[ISATR_MAX_ADAPTERS];
static struct net_device * __init setup_card(unsigned long io, unsigned irq, unsigned char dma)
{
int res = -ENOMEM;
struct proteon_card *this_card;
struct net_device *dev = alloc_trdev(0);
if (dev) {
dev->base_addr = io;
dev->irq = irq;
dev->dma = dma;
res = -ENODEV;
if (proteon_probe(dev) == 0) {
res = register_netdev(dev);
if (!res)
return 0;
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
this_card = proteon_card_list;
proteon_card_list = this_card->next;
kfree(this_card);
}
kfree(dev);
}
return res;
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
dev->irq = irq;
dev->dma = dma;
err = proteon_probe1(dev, io);
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
out:
free_netdev(dev);
return ERR_PTR(err);
}
int init_module(void)
{
int i, num;
num = 0;
if (io[0]) { /* Only probe addresses from command line */
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
if (io[i] && setup_card(io[i], irq[i], dma[i]) == 0)
num++;
}
} else {
for(i = 0; num < ISATR_MAX_ADAPTERS && portlist[i]; i++) {
if (setup_card(portlist[i], irq[num], dma[num]) == 0)
num++;
struct net_device *dev;
int i, num = 0;
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
dev = io[0] ? setup_card(io[i], irq[i], dma[i])
: proteon_probe(-1);
if (!IS_ERR(dev)) {
proteon_dev[i] = dev;
++num;
}
}
printk(KERN_NOTICE "proteon.c: %d cards found.\n", num);
/* Probe for cards. */
if (num == 0) {
......@@ -425,11 +412,13 @@ int init_module(void)
void cleanup_module(void)
{
struct net_device *dev;
struct proteon_card *this_card;
int i;
while (proteon_card_list) {
dev = proteon_card_list->dev;
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
struct net_device *dev = proteon_dev[i];
if (!dev)
continue;
unregister_netdev(dev);
release_region(dev->base_addr, PROTEON_IO_EXTENT);
......@@ -437,9 +426,6 @@ void cleanup_module(void)
free_dma(dev->dma);
tmsdev_term(dev);
free_netdev(dev);
this_card = proteon_card_list;
proteon_card_list = this_card->next;
kfree(this_card);
}
}
#endif /* MODULE */
......
......@@ -56,7 +56,7 @@ static unsigned int portlist[] __initdata = {
/* A zero-terminated list of IRQs to be probed.
* Used again after initial probe for sktr_chipset_init, called from sktr_open.
*/
static unsigned short irqlist[] = {
static const unsigned short irqlist[] = {
3, 5, 9, 10, 11, 12, 15,
0
};
......@@ -69,7 +69,6 @@ static int dmalist[] __initdata = {
static char isa_cardname[] = "SK NET TR 4/16 ISA\0";
int sk_isa_probe(struct net_device *dev);
static int sk_isa_open(struct net_device *dev);
static int sk_isa_close(struct net_device *dev);
static void sk_isa_read_eeprom(struct net_device *dev);
......@@ -95,17 +94,14 @@ static void sk_isa_sifwritew(struct net_device *dev, unsigned short val, unsigne
outw(val, dev->base_addr + reg);
}
struct sk_isa_card {
struct net_device *dev;
struct sk_isa_card *next;
};
static struct sk_isa_card *sk_isa_card_list;
static int __init sk_isa_probe1(int ioaddr)
static int __init sk_isa_probe1(struct net_device *dev, int ioaddr)
{
unsigned char old, chk1, chk2;
if (!request_region(ioaddr, SK_ISA_IO_EXTENT, isa_cardname))
return -ENODEV;
old = inb(ioaddr + SIFADR); /* Get the old SIFADR value */
chk1 = 0; /* Begin with check value 0 */
......@@ -122,8 +118,10 @@ static int __init sk_isa_probe1(int ioaddr)
chk2 = inb(ioaddr + SIFADD);
chk2 ^= 0x0FE;
if(chk1 != chk2)
return (-1); /* No adapter */
if(chk1 != chk2) {
release_region(ioaddr, SK_ISA_IO_EXTENT);
return -ENODEV;
}
chk1 -= 2;
} while(chk1 != 0); /* Repeat 128 times (all byte values) */
......@@ -131,58 +129,45 @@ static int __init sk_isa_probe1(int ioaddr)
/* Restore the SIFADR value */
outb(old, ioaddr + SIFADR);
return (0);
dev->base_addr = ioaddr;
return 0;
}
int __init sk_isa_probe(struct net_device *dev)
struct net_device * __init sk_isa_probe(int unit)
{
static int versionprinted;
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
struct net_local *tp;
int i,j;
struct sk_isa_card *card;
static int versionprinted;
const unsigned *port;
int j, err = 0;
#ifndef MODULE
netdev_boot_setup_check(dev);
tr_setup(dev);
#endif
if (!dev)
return ERR_PTR(-ENOMEM);
SET_MODULE_OWNER(dev);
if (!dev->base_addr)
{
for(i = 0; portlist[i]; i++)
{
if (!request_region(portlist[i], SK_ISA_IO_EXTENT, isa_cardname))
continue;
if(sk_isa_probe1(portlist[i]))
{
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
continue;
}
if (unit >= 0) {
sprintf(dev->name, "tr%d", unit);
netdev_boot_setup_check(dev);
}
dev->base_addr = portlist[i];
break;
SET_MODULE_OWNER(dev);
if (dev->base_addr) /* probe specific location */
err = sk_isa_probe1(dev, dev->base_addr);
else {
for (port = portlist; *port; port++) {
err = sk_isa_probe1(dev, *port);
if (!err)
break;
}
if(!dev->base_addr)
return -1;
}
else
{
if (!request_region(dev->base_addr, SK_ISA_IO_EXTENT, isa_cardname))
return -1;
if(sk_isa_probe1(dev->base_addr))
{
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
return -1;
}
}
if (err)
goto out4;
/* At this point we have found a valid card. */
if (versionprinted++ == 0)
printk(KERN_DEBUG "%s", version);
err = -EIO;
if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL))
goto out4;
......@@ -284,14 +269,11 @@ int __init sk_isa_probe(struct net_device *dev)
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
dev->name, dev->base_addr, dev->irq, dev->dma);
/* Enlist in the card list */
card = kmalloc(sizeof(struct sk_isa_card), GFP_KERNEL);
if (!card)
err = register_netdev(dev);
if (err)
goto out;
card->next = sk_isa_card_list;
sk_isa_card_list = card;
card->dev = dev;
return 0;
return dev;
out:
free_dma(dev->dma);
out2:
......@@ -300,7 +282,8 @@ int __init sk_isa_probe(struct net_device *dev)
tmsdev_term(dev);
out4:
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
return -1;
free_netdev(dev);
return ERR_PTR(err);
}
/*
......@@ -373,6 +356,8 @@ static int sk_isa_close(struct net_device *dev)
#define ISATR_MAX_ADAPTERS 3
static struct net_device *sk_isa_dev[ISATR_MAX_ADAPTERS];
static int io[ISATR_MAX_ADAPTERS];
static int irq[ISATR_MAX_ADAPTERS];
static int dma[ISATR_MAX_ADAPTERS];
......@@ -383,50 +368,54 @@ MODULE_PARM(io, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
MODULE_PARM(irq, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
MODULE_PARM(dma, "1-" __MODULE_STRING(ISATR_MAX_ADAPTERS) "i");
static int __init setup_card(unsigned long io, unsigned irq, unsigned char dma)
static struct net_device * __init setup_card(unsigned long io, unsigned irq, unsigned char dma)
{
int res = -ENOMEM;
struct sk_isa_card *this_card;
struct net_device *dev = alloc_trdev(0);
if (dev) {
dev->base_addr = io;
dev->irq = irq;
dev->dma = dma;
res = -ENODEV;
if (sk_isa_probe(dev) == 0) {
res = register_netdev(dev);
if (!res)
return 0;
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
this_card = sk_isa_card_list;
sk_isa_card_list = this_card->next;
kfree(this_card);
}
kfree(dev);
}
return res;
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
dev->base_addr = io;
dev->irq = irq;
dev->dma = dma;
err = sk_isa_probe1(dev, io);
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev);
free_dma(dev->dma);
tmsdev_term(dev);
out:
free_netdev(dev);
return ERR_PTR(err);
}
int init_module(void)
{
struct net_device *dev;
int i, num;
num = 0;
if (io[0]) { /* Only probe addresses from command line */
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
if (io[i] && setup_card(io[i], irq[i], dma[i]) == 0)
num++;
}
} else {
for(i = 0; num < ISATR_MAX_ADAPTERS && portlist[i]; i++) {
if (setup_card(portlist[i], irq[num], dma[num]) == 0)
num++;
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
if (io[0]) /* Only probe addresses from command line */
dev = setup_card(io[i], irq[i], dma[i]);
else
dev = sk_isa_probe(-1);
if (!IS_ERR(dev)) {
sk_isa_dev[i] = dev;
++num;
}
}
printk(KERN_NOTICE "skisa.c: %d cards found.\n", num);
/* Probe for cards. */
if (num == 0) {
......@@ -438,11 +427,13 @@ int init_module(void)
void cleanup_module(void)
{
struct net_device *dev;
struct sk_isa_card *this_card;
int i;
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
struct net_device *dev = sk_isa_dev[i];
while (sk_isa_card_list) {
dev = sk_isa_card_list->dev;
if (!dev)
continue;
unregister_netdev(dev);
release_region(dev->base_addr, SK_ISA_IO_EXTENT);
......@@ -450,9 +441,6 @@ void cleanup_module(void)
free_dma(dev->dma);
tmsdev_term(dev);
free_netdev(dev);
this_card = sk_isa_card_list;
sk_isa_card_list = this_card->next;
kfree(this_card);
}
}
#endif /* MODULE */
......
......@@ -69,13 +69,6 @@ static const char cardname[] = "smctr";
#define SMCTR_IO_EXTENT 20
/* A zero-terminated list of I/O addresses to be probed. */
static unsigned int smctr_portlist[] __initdata = {
0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0, 0x300,
0x320, 0x340, 0x360, 0x380,
0
};
#ifdef CONFIG_MCA
static unsigned int smctr_posid = 0x6ec6;
#endif
......@@ -219,7 +212,7 @@ static int smctr_open(struct net_device *dev);
static int smctr_open_tr(struct net_device *dev);
/* P */
int __init smctr_probe (struct net_device *dev);
struct net_device *smctr_probe(int unit);
static int __init smctr_probe1(struct net_device *dev, int ioaddr);
static int smctr_process_rx_packet(MAC_HEADER *rmf, __u16 size,
struct net_device *dev, __u16 rx_status);
......@@ -3583,71 +3576,72 @@ static int smctr_open_tr(struct net_device *dev)
return (err);
}
/* Check for a network adapter of this type, and return '0 if one exists.
* If dev->base_addr == 0, probe all likely locations.
* If dev->base_addr == 1, always return failure.
/* Check for a network adapter of this type,
* and return device structure if one exists.
*/
int __init smctr_probe (struct net_device *dev)
{
int i;
int base_addr;
struct net_device __init *smctr_probe(int unit)
{
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
static const unsigned ports[] = {
0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0, 0x300,
0x320, 0x340, 0x360, 0x380, 0
};
const unsigned *port;
int err = 0;
#ifndef MODULE
netdev_boot_setup_check(dev);
tr_setup(dev);
#endif
if (!dev)
return ERR_PTR(-ENOMEM);
base_addr = dev->base_addr;
if(base_addr > 0x1ff) /* Check a single specified location. */
return (smctr_probe1(dev, base_addr));
else if(base_addr != 0) /* Don't probe at all. */
return (-ENXIO);
SET_MODULE_OWNER(dev);
for(i = 0; smctr_portlist[i]; i++)
{
int ioaddr = smctr_portlist[i];
if (!smctr_probe1(dev, ioaddr))
return (0);
}
return (-ENODEV);
}
if (unit >= 0) {
sprintf(dev->name, "tr%d", unit);
netdev_boot_setup_check(dev);
}
static void cleanup_card(struct net_device *dev)
{
if (dev->base_addr > 0x1ff) /* Check a single specified location. */
err = smctr_probe1(dev, dev->base_addr);
else if(dev->base_addr != 0) /* Don't probe at all. */
err =-ENXIO;
else {
for (port = ports; *port; port++) {
err = smctr_probe1(dev, *port);
if (!err)
break;
}
}
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
#ifdef CONFIG_MCA
struct net_local *tp = (struct net_local *)dev->priv;
if (tp->slot_num)
{ struct net_local *tp = (struct net_local *)dev->priv;
if (tp->slot_num)
mca_mark_as_unused(tp->slot_num);
}
#endif
release_region(dev->base_addr, SMCTR_IO_EXTENT);
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->priv)
kfree(dev->priv);
free_irq(dev->irq, dev);
out:
free_netdev(dev);
return ERR_PTR(err);
}
static int __init smctr_probe1(struct net_device *dev, int ioaddr)
{
static unsigned version_printed;
struct net_local *tp;
struct net_local *tp = dev->priv;
int err;
__u32 *ram;
if(smctr_debug && version_printed++ == 0)
printk(version);
/* Setup this devices private information structure */
tp = (struct net_local *)kmalloc(sizeof(struct net_local),
GFP_KERNEL);
if(tp == NULL) {
err = -ENOMEM;
goto out;
}
memset(tp, 0, sizeof(struct net_local));
spin_lock_init(&tp->lock);
dev->priv = tp;
dev->base_addr = ioaddr;
/* Actually detect an adapter now. */
......@@ -3656,7 +3650,7 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
{
if ((err = smctr_chk_mca(dev)) < 0) {
err = -ENODEV;
goto out_tp;
goto out;
}
}
......@@ -3671,7 +3665,6 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
if(err != UCODE_PRESENT && err != SUCCESS)
{
printk(KERN_ERR "%s: Firmware load failed (%d)\n", dev->name, err);
cleanup_card(dev);
err = -EIO;
goto out;
}
......@@ -3696,8 +3689,6 @@ static int __init smctr_probe1(struct net_device *dev, int ioaddr)
dev->set_multicast_list = &smctr_set_multicast_list;
return (0);
out_tp:
kfree(tp);
out:
return err;
}
......@@ -5669,47 +5660,59 @@ static int smctr_wait_while_cbusy(struct net_device *dev)
static struct net_device* dev_smctr[SMCTR_MAX_ADAPTERS];
static int io[SMCTR_MAX_ADAPTERS];
static int irq[SMCTR_MAX_ADAPTERS];
static int mem[SMCTR_MAX_ADAPTERS];
MODULE_LICENSE("GPL");
MODULE_PARM(io, "1-" __MODULE_STRING(SMCTR_MAX_ADAPTERS) "i");
MODULE_PARM(io, "1-" __MODULE_STRING(SMCTR_MAX_ADAPTERS) "i");
MODULE_PARM(irq, "1-" __MODULE_STRING(SMCTR_MAX_ADAPTERS) "i");
MODULE_PARM(mem, "1-" __MODULE_STRING(SMCTR_MAX_ADAPTERS) "i");
MODULE_PARM(ringspeed, "1-" __MODULE_STRING(SMCTR_MAX_ADAPTERS) "i");
MODULE_PARM(ringspeed, "i");
static struct net_device *setup_card(int n)
{
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
int err;
if (!dev)
return ERR_PTR(-ENOMEM);
dev->irq = irq[n];
err = smctr_probe1(dev, io[n]);
if (err)
goto out;
err = register_netdev(dev);
if (err)
goto out1;
return dev;
out1:
#ifdef CONFIG_MCA
{ struct net_local *tp = (struct net_local *)dev->priv;
if (tp->slot_num)
mca_mark_as_unused(tp->slot_num);
}
#endif
release_region(dev->base_addr, SMCTR_IO_EXTENT);
free_irq(dev->irq, dev);
out:
free_netdev(dev);
return ERR_PTR(err);
}
int init_module(void)
{
int i;
int i, found = 0;
struct net_device *dev;
for(i = 0; i < SMCTR_MAX_ADAPTERS; i++) {
struct net_device *dev = alloc_trdev(0);
irq[i] = 0;
mem[i] = 0;
if (!dev)
return -ENOMEM;
dev->base_addr = io[i];
dev->irq = irq[i];
dev->mem_start = mem[i];
if (smctr_probe(dev) != 0) {
kfree(dev);
if (i == 0) {
printk(KERN_ERR "%s: smctr_probe failed.\n",
cardname);
return -EIO;
}
return 0;
}
if (register_netdev(dev) != 0) {
cleanup_card(dev);
kfree(dev);
continue;
}
dev_smctr[i] = dev;
dev = io[0]? setup_card(i) : smctr_probe(-1);
if (!IS_ERR(dev)) {
++found;
dev_smctr[i] = dev;
}
}
return (0);
return found ? 0 : -ENODEV;
}
void cleanup_module(void)
......@@ -5718,9 +5721,20 @@ void cleanup_module(void)
for(i = 0; i < SMCTR_MAX_ADAPTERS; i++) {
struct net_device *dev = dev_smctr[i];
if (dev) {
unregister_netdev(dev);
cleanup_card(dev);
#ifdef CONFIG_MCA
{ struct net_local *tp = dev->priv;
if (tp->slot_num)
mca_mark_as_unused(tp->slot_num);
}
#endif
release_region(dev->base_addr, SMCTR_IO_EXTENT);
if (dev->irq)
free_irq(dev->irq, dev);
free_netdev(dev);
}
}
......
......@@ -377,6 +377,7 @@ static struct tun_struct *tun_get_by_name(const char *name)
static int tun_set_iff(struct file *file, struct ifreq *ifr)
{
struct tun_struct *tun;
struct net_device *dev;
int err;
tun = tun_get_by_name(ifr->ifr_name);
......@@ -394,7 +395,6 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
else {
char *name;
unsigned long flags = 0;
struct net_device *dev;
err = -EINVAL;
......@@ -424,16 +424,13 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
if (strchr(dev->name, '%')) {
err = dev_alloc_name(dev, dev->name);
if (err < 0) {
kfree(dev);
goto failed;
}
if (err < 0)
goto err_free_dev;
}
if ((err = register_netdevice(tun->dev))) {
kfree(dev);
goto failed;
}
err = register_netdevice(tun->dev);
if (err < 0)
goto err_free_dev;
list_add(&tun->list, &tun_dev_list);
}
......@@ -451,6 +448,9 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
strcpy(ifr->ifr_name, tun->dev->name);
return 0;
err_free_dev:
free_netdev(dev);
failed:
return err;
}
......
This diff is collapsed.
......@@ -390,7 +390,7 @@ struct lmc___softc {
struct timer_list timer;
lmc_ctl_t ictl;
u_int32_t TxDescriptControlInit;
struct net_device *next_module; /* Link to the next module */
int tx_TimeoutInd; /* additional driver state */
int tx_TimeoutDisplay;
unsigned int lastlmc_taint_tx;
......@@ -519,18 +519,7 @@ struct lmc___softc {
#define TULIP_CMD_RECEIVEALL 0x40000000L
#endif
/* PCI register values */
#define CORRECT_VENDOR_ID 0x1011
#define CORRECT_DEV_ID 9
#define PCI_VENDOR_LMC 0x1376
#define PCI_PRODUCT_LMC_HSSI 0x0003
#define PCI_PRODUCT_LMC_DS3 0x0004
#define PCI_PRODUCT_LMC_SSI 0x0005
#define PCI_PRODUCT_LMC_T1 0x0006
/* Adapcter module number */
/* Adapter module number */
#define LMC_ADAP_HSSI 2
#define LMC_ADAP_DS3 3
#define LMC_ADAP_SSI 4
......
This diff is collapsed.
......@@ -57,12 +57,8 @@ extern int arlan_command(struct net_device * dev, int command);
#define SIDUNKNOWN -1
#define radioNodeIdUNKNOWN -1
#define encryptionKeyUNKNOWN '\0';
#define irqUNKNOWN 0
#define memUNKNOWN 0
#define debugUNKNOWN 0
#define probeUNKNOWN 1
#define numDevicesUNKNOWN 1
#define testMemoryUNKNOWN 1
#define spreadingCodeUNKNOWN 0
#define channelNumberUNKNOWN 0
......@@ -82,6 +78,8 @@ extern int arlan_command(struct net_device * dev, int command);
#define ARLAN_DEBUG(a,b)
#endif
#define ARLAN_SHMEM_SIZE 0x2000
struct arlan_shmem
{
/* Header Signature */
......
......@@ -4091,12 +4091,24 @@ static int wavelan_close(device * dev)
* device structure
* (called by wavelan_probe() and via init_module()).
*/
static int __init wavelan_config(device * dev)
static int __init wavelan_config(device *dev, unsigned short ioaddr)
{
unsigned long ioaddr = dev->base_addr;
u8 irq_mask;
int irq;
net_local *lp;
mac_addr mac;
int err;
if (!request_region(ioaddr, sizeof(ha_t), "wavelan"))
return -EADDRINUSE;
err = wv_check_ioaddr(ioaddr, mac);
if (err)
goto out;
memcpy(dev->dev_addr, mac, 6);
dev->base_addr = ioaddr;
#ifdef DEBUG_CALLBACK_TRACE
printk(KERN_DEBUG "%s: ->wavelan_config(dev=0x%x, ioaddr=0x%lx)\n",
......@@ -4136,25 +4148,18 @@ static int __init wavelan_config(device * dev)
"%s: wavelan_config(): could not wavelan_map_irq(%d).\n",
dev->name, irq_mask);
#endif
return -EAGAIN;
err = -EAGAIN;
goto out;
}
dev->irq = irq;
if (!request_region(ioaddr, sizeof(ha_t), "wavelan"))
return -EBUSY;
dev->mem_start = 0x0000;
dev->mem_end = 0x0000;
dev->if_port = 0;
/* Initialize device structures */
dev->priv = kmalloc(sizeof(net_local), GFP_KERNEL);
if (dev->priv == NULL) {
release_region(ioaddr, sizeof(ha_t));
return -ENOMEM;
}
memset(dev->priv, 0x00, sizeof(net_local));
memset(dev->priv, 0, sizeof(net_local));
lp = (net_local *) dev->priv;
/* Back link to the device structure. */
......@@ -4172,12 +4177,6 @@ static int __init wavelan_config(device * dev)
/* Init spinlock */
spin_lock_init(&lp->spinlock);
/*
* Fill in the fields of the device structure
* with generic Ethernet values.
*/
ether_setup(dev);
SET_MODULE_OWNER(dev);
dev->open = wavelan_open;
dev->stop = wavelan_close;
......@@ -4204,6 +4203,9 @@ static int __init wavelan_config(device * dev)
printk(KERN_DEBUG "%s: <-wavelan_config()\n", dev->name);
#endif
return 0;
out:
release_region(ioaddr, sizeof(ha_t));
return err;
}
/*------------------------------------------------------------------*/
......@@ -4214,19 +4216,13 @@ static int __init wavelan_config(device * dev)
* We follow the example in drivers/net/ne.c.
* (called in "Space.c")
*/
int __init wavelan_probe(device * dev)
struct net_device * __init wavelan_probe(int unit)
{
struct net_device *dev;
short base_addr;
mac_addr mac; /* MAC address (check existence of WaveLAN) */
int def_irq;
int i;
int r;
#ifdef DEBUG_CALLBACK_TRACE
printk(KERN_DEBUG
"%s: ->wavelan_probe(dev=0x%x (base_addr=0x%x))\n",
dev->name, (unsigned int) dev,
(unsigned int) dev->base_addr);
#endif
int r = 0;
#ifdef STRUCT_CHECK
if (wv_struct_check() != (char *) NULL) {
......@@ -4237,8 +4233,20 @@ int __init wavelan_probe(device * dev)
}
#endif /* STRUCT_CHECK */
/* Check the value of the command line parameter for base address. */
dev = alloc_etherdev(sizeof(net_local));
if (!dev)
return ERR_PTR(-ENOMEM);
sprintf(dev->name, "eth%d", unit);
netdev_boot_setup_check(dev);
base_addr = dev->base_addr;
def_irq = dev->irq;
#ifdef DEBUG_CALLBACK_TRACE
printk(KERN_DEBUG
"%s: ->wavelan_probe(dev=%p (base_addr=0x%x))\n",
dev->name, dev, (unsigned int) dev->base_addr);
#endif
/* Don't probe at all. */
if (base_addr < 0) {
......@@ -4247,16 +4255,9 @@ int __init wavelan_probe(device * dev)
"%s: wavelan_probe(): invalid base address\n",
dev->name);
#endif
return -ENXIO;
}
/* Check a single specified location. */
if (base_addr > 0x100) {
/* Check if there is something at this base address */
if ((r = wv_check_ioaddr(base_addr, mac)) == 0) {
memcpy(dev->dev_addr, mac, 6); /* Copy MAC address. */
r = wavelan_config(dev);
}
r = -ENXIO;
} else if (base_addr > 0x100) { /* Check a single specified location. */
r = wavelan_config(dev, base_addr);
#ifdef DEBUG_CONFIG_INFO
if (r != 0)
printk(KERN_DEBUG
......@@ -4267,35 +4268,33 @@ int __init wavelan_probe(device * dev)
#ifdef DEBUG_CALLBACK_TRACE
printk(KERN_DEBUG "%s: <-wavelan_probe()\n", dev->name);
#endif
return r;
}
/* Scan all possible addresses of the WaveLAN hardware. */
for (i = 0; i < NELS(iobase); i++) {
/* Check whether there is something at this base address. */
if (wv_check_ioaddr(iobase[i], mac) == 0) {
dev->base_addr = iobase[i]; /* Copy base address. */
memcpy(dev->dev_addr, mac, 6); /* Copy MAC address. */
if (wavelan_config(dev) == 0) {
} else { /* Scan all possible addresses of the WaveLAN hardware. */
for (i = 0; i < NELS(iobase); i++) {
dev->irq = def_irq;
if (wavelan_config(dev, iobase[i]) == 0) {
#ifdef DEBUG_CALLBACK_TRACE
printk(KERN_DEBUG
"%s: <-wavelan_probe()\n",
dev->name);
#endif
return 0;
break;
}
}
if (i == NELS(iobase))
r = -ENODEV;
}
/* We may have touched base_addr. Another driver may not like it. */
dev->base_addr = base_addr;
#ifdef DEBUG_CONFIG_INFO
printk(KERN_DEBUG "%s: wavelan_probe(): no device found\n",
dev->name);
#endif
return -ENODEV;
if (r)
goto out;
r = register_netdev(dev);
if (r)
goto out1;
return dev;
out1:
release_region(dev->base_addr, sizeof(ha_t));
wavelan_list = wavelan_list->next;
out:
kfree(dev);
return ERR_PTR(r);
}
/****************************** MODULE ******************************/
......@@ -4311,7 +4310,6 @@ int __init wavelan_probe(device * dev)
*/
int init_module(void)
{
mac_addr mac; /* MAC address (check WaveLAN existence) */
int ret = -EIO; /* Return error if no cards found */
int i;
......@@ -4337,38 +4335,28 @@ int init_module(void)
/* Loop on all possible base addresses. */
i = -1;
while ((io[++i] != 0) && (i < NELS(io))) {
struct net_device *dev = alloc_etherdev(sizeof(net_local));
if (!dev)
break;
memcpy(dev->name, name[i], IFNAMSIZ); /* Copy name */
dev->base_addr = io[i];
dev->irq = irq[i];
/* Check if there is something at this base address. */
if (wv_check_ioaddr(io[i], mac) == 0) {
device *dev;
/* Create device and set basic arguments. */
dev =
kmalloc(sizeof(struct net_device), GFP_KERNEL);
if (dev == NULL) {
ret = -ENOMEM;
break;
}
memset(dev, 0x00, sizeof(struct net_device));
memcpy(dev->name, name[i], IFNAMSIZ); /* Copy name */
dev->base_addr = io[i];
dev->irq = irq[i];
dev->init = &wavelan_config;
memcpy(dev->dev_addr, mac, 6); /* Copy MAC address. */
/* Try to create the device. */
if (wavelan_config(dev, io[i]) == 0) {
if (register_netdev(dev) != 0) {
/* Deallocate everything. */
/* Note: if dev->priv is mallocated, there is no way to fail. */
kfree(dev);
release_region(dev->base_addr, sizeof(ha_t));
wavelan_list = wavelan_list->next;
} else {
/* If at least one device OK, we do not fail */
ret = 0;
continue;
}
} /* if there is something at the address */
} /* Loop on all addresses. */
}
kfree(dev);
}
#ifdef DEBUG_CONFIG_ERROR
if (wavelan_list == (net_local *) NULL)
if (!wavelan_list)
printk(KERN_WARNING
"WaveLAN init_module(): no device found\n");
#endif
......@@ -4390,7 +4378,7 @@ void cleanup_module(void)
#endif
/* Loop on all devices and release them. */
while (wavelan_list != (net_local *) NULL) {
while (wavelan_list) {
device *dev = wavelan_list->dev;
#ifdef DEBUG_CONFIG_INFO
......@@ -4398,18 +4386,11 @@ void cleanup_module(void)
"%s: cleanup_module(): removing device at 0x%x\n",
dev->name, (unsigned int) dev);
#endif
/* Release the ioport region. */
release_region(dev->base_addr, sizeof(ha_t));
/* Definitely remove the device. */
unregister_netdev(dev);
/* Unlink the device. */
release_region(dev->base_addr, sizeof(ha_t));
wavelan_list = wavelan_list->next;
/* Free pieces. */
kfree(dev->priv);
free_netdev(dev);
}
......
......@@ -656,9 +656,8 @@ static void
static int
wavelan_open(device *), /* Open the device. */
wavelan_close(device *), /* Close the device. */
wavelan_config(device *); /* Configure one device. */
extern int
wavelan_probe(device *); /* See Space.c. */
wavelan_config(device *, unsigned short);/* Configure one device. */
extern struct net_device *wavelan_probe(int unit); /* See Space.c. */
/**************************** VARIABLES ****************************/
......
......@@ -496,6 +496,7 @@ extern rwlock_t dev_base_lock; /* Device list lock */
extern int netdev_boot_setup_add(char *name, struct ifmap *map);
extern int netdev_boot_setup_check(struct net_device *dev);
extern unsigned long netdev_boot_base(const char *prefix, int unit);
extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr);
extern struct net_device *__dev_getfirstbyhwtype(unsigned short type);
extern struct net_device *dev_getfirstbyhwtype(unsigned short type);
......
......@@ -371,6 +371,30 @@ int netdev_boot_setup_check(struct net_device *dev)
return 0;
}
/**
* netdev_boot_base - get address from boot time settings
* @prefix: prefix for network device
* @unit: id for network device
*
* Check boot time settings for the base address of device.
* The found settings are set for the device to be used
* later in the device probing.
* Returns 0 if no settings found.
*/
unsigned long netdev_boot_base(const char *prefix, int unit)
{
const struct netdev_boot_setup *s = dev_boot_setup;
char name[IFNAMSIZ];
int i;
sprintf(name, "%s%d", prefix, unit);
for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++)
if (!strcmp(name, s[i].name))
return s[i].map.base_addr;
return 0;
}
/*
* Saves at boot time configured settings for any netdevice.
*/
......
......@@ -726,8 +726,6 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
if (dev->name == NULL) {
err = -EINVAL;
} else if (dev_get(dev->name)) {
err = -EEXIST; /* name already exists */
} else {
#ifdef WANDEBUG
......
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