Commit ca3d0fae authored by David S. Miller's avatar David S. Miller Committed by Stephen Hemminger

[NET]: Convert sunlance away from init_etherdev.

parent a5bb67e9
...@@ -1312,32 +1312,24 @@ static struct ethtool_ops sparc_lance_ethtool_ops = { ...@@ -1312,32 +1312,24 @@ static struct ethtool_ops sparc_lance_ethtool_ops = {
.get_link = sparc_lance_get_link, .get_link = sparc_lance_get_link,
}; };
static int __init sparc_lance_init(struct net_device *dev, static int __init sparc_lance_init(struct sbus_dev *sdev,
struct sbus_dev *sdev,
struct sbus_dma *ledma, struct sbus_dma *ledma,
struct sbus_dev *lebuffer) struct sbus_dev *lebuffer)
{ {
static unsigned version_printed; static unsigned version_printed;
struct lance_private *lp = NULL; struct net_device *dev;
struct lance_private *lp;
int i; int i;
if (dev == NULL) { dev = alloc_etherdev(sizeof(struct lance_private) + 8);
dev = init_etherdev (0, sizeof (struct lance_private) + 8); if (!dev)
} else { return -ENOMEM;
dev->priv = kmalloc(sizeof (struct lance_private) + 8,
GFP_KERNEL); lp = dev->priv;
if (dev->priv == NULL)
return -ENOMEM;
memset(dev->priv, 0, sizeof (struct lance_private) + 8);
}
if (sparc_lance_debug && version_printed++ == 0) if (sparc_lance_debug && version_printed++ == 0)
printk (KERN_INFO "%s", version); printk (KERN_INFO "%s", version);
printk(KERN_INFO "%s: LANCE ", dev->name);
/* Make certain the data structures used by the LANCE are aligned. */
dev->priv = (void *)(((unsigned long)dev->priv + 7) & ~7);
lp = (struct lance_private *) dev->priv;
spin_lock_init(&lp->lock); spin_lock_init(&lp->lock);
/* Copy the IDPROM ethernet address to the device structure, later we /* Copy the IDPROM ethernet address to the device structure, later we
...@@ -1345,16 +1337,13 @@ static int __init sparc_lance_init(struct net_device *dev, ...@@ -1345,16 +1337,13 @@ static int __init sparc_lance_init(struct net_device *dev,
* initialization block. * initialization block.
*/ */
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
printk("%2.2x%c", dev->dev_addr[i] = idprom->id_ethaddr[i], dev->dev_addr[i] = idprom->id_ethaddr[i];
i == 5 ? ' ': ':');
printk("\n");
/* Get the IO region */ /* Get the IO region */
lp->lregs = sbus_ioremap(&sdev->resource[0], 0, lp->lregs = sbus_ioremap(&sdev->resource[0], 0,
LANCE_REG_SIZE, lancestr); LANCE_REG_SIZE, lancestr);
if (lp->lregs == 0UL) { if (lp->lregs == 0UL) {
printk(KERN_ERR "%s: Cannot map SunLance registers.\n", printk(KERN_ERR "SunLance: Cannot map registers.\n");
dev->name);
goto fail; goto fail;
} }
...@@ -1364,8 +1353,7 @@ static int __init sparc_lance_init(struct net_device *dev, ...@@ -1364,8 +1353,7 @@ static int __init sparc_lance_init(struct net_device *dev,
sbus_ioremap(&lebuffer->resource[0], 0, sbus_ioremap(&lebuffer->resource[0], 0,
sizeof(struct lance_init_block), "lebuffer"); sizeof(struct lance_init_block), "lebuffer");
if (lp->init_block == NULL) { if (lp->init_block == NULL) {
printk(KERN_ERR "%s: Cannot map SunLance PIO buffer.\n", printk(KERN_ERR "SunLance: Cannot map PIO buffer.\n");
dev->name);
goto fail; goto fail;
} }
lp->init_block_dvma = 0; lp->init_block_dvma = 0;
...@@ -1379,8 +1367,7 @@ static int __init sparc_lance_init(struct net_device *dev, ...@@ -1379,8 +1367,7 @@ static int __init sparc_lance_init(struct net_device *dev,
&lp->init_block_dvma); &lp->init_block_dvma);
if (lp->init_block == NULL || if (lp->init_block == NULL ||
lp->init_block_dvma == 0) { lp->init_block_dvma == 0) {
printk(KERN_ERR "%s: Cannot allocate consistent DMA memory.\n", printk(KERN_ERR "SunLance: Cannot allocate consistent DMA memory.\n");
dev->name);
goto fail; goto fail;
} }
lp->pio_buffer = 0; lp->pio_buffer = 0;
...@@ -1418,8 +1405,7 @@ static int __init sparc_lance_init(struct net_device *dev, ...@@ -1418,8 +1405,7 @@ static int __init sparc_lance_init(struct net_device *dev,
if (prop[0] == 0) { if (prop[0] == 0) {
int topnd, nd; int topnd, nd;
printk(KERN_INFO "%s: using auto-carrier-detection.\n", printk(KERN_INFO "SunLance: using auto-carrier-detection.\n");
dev->name);
/* Is this found at /options .attributes in all /* Is this found at /options .attributes in all
* Prom versions? XXX * Prom versions? XXX
...@@ -1438,10 +1424,10 @@ static int __init sparc_lance_init(struct net_device *dev, ...@@ -1438,10 +1424,10 @@ static int __init sparc_lance_init(struct net_device *dev,
sizeof(prop)); sizeof(prop));
if (strcmp(prop, "true")) { if (strcmp(prop, "true")) {
printk(KERN_NOTICE "%s: warning: overriding option " printk(KERN_NOTICE "SunLance: warning: overriding option "
"'tpe-link-test?'\n", dev->name); "'tpe-link-test?'\n");
printk(KERN_NOTICE "%s: warning: mail any problems " printk(KERN_NOTICE "SunLance: warning: mail any problems "
"to ecd@skynet.be\n", dev->name); "to ecd@skynet.be\n");
auxio_set_lte(AUXIO_LTE_ON); auxio_set_lte(AUXIO_LTE_ON);
} }
no_link_test: no_link_test:
...@@ -1467,8 +1453,7 @@ static int __init sparc_lance_init(struct net_device *dev, ...@@ -1467,8 +1453,7 @@ static int __init sparc_lance_init(struct net_device *dev,
/* This should never happen. */ /* This should never happen. */
if ((unsigned long)(lp->init_block->brx_ring) & 0x07) { if ((unsigned long)(lp->init_block->brx_ring) & 0x07) {
printk(KERN_ERR "%s: ERROR: Rx and Tx rings not on even boundary.\n", printk(KERN_ERR "SunLance: ERROR: Rx and Tx rings not on even boundary.\n");
dev->name);
goto fail; goto fail;
} }
...@@ -1486,7 +1471,6 @@ static int __init sparc_lance_init(struct net_device *dev, ...@@ -1486,7 +1471,6 @@ static int __init sparc_lance_init(struct net_device *dev,
dev->irq = sdev->irqs[0]; dev->irq = sdev->irqs[0];
dev->dma = 0; dev->dma = 0;
ether_setup(dev);
/* We cannot sleep if the chip is busy during a /* We cannot sleep if the chip is busy during a
* multicast list update event, because such events * multicast list update event, because such events
...@@ -1497,15 +1481,27 @@ static int __init sparc_lance_init(struct net_device *dev, ...@@ -1497,15 +1481,27 @@ static int __init sparc_lance_init(struct net_device *dev,
lp->multicast_timer.data = (unsigned long) dev; lp->multicast_timer.data = (unsigned long) dev;
lp->multicast_timer.function = &lance_set_multicast_retry; lp->multicast_timer.function = &lance_set_multicast_retry;
dev->ifindex = dev_new_index(); if (register_netdev(dev)) {
printk(KERN_ERR "SunLance: Cannot register device.\n");
goto fail;
}
lp->next_module = root_lance_dev; lp->next_module = root_lance_dev;
root_lance_dev = lp; root_lance_dev = lp;
printk(KERN_INFO "%s: LANCE ", dev->name);
for (i = 0; i < 6; i++)
printk("%2.2x%c", dev->dev_addr[i],
i == 5 ? ' ': ':');
printk("\n");
return 0; return 0;
fail: fail:
if (lp != NULL) if (lp != NULL)
lance_free_hwresources(lp); lance_free_hwresources(lp);
free_netdev(dev);
return -ENODEV; return -ENODEV;
} }
...@@ -1543,7 +1539,7 @@ static int __init sparc_lance_probe(void) ...@@ -1543,7 +1539,7 @@ static int __init sparc_lance_probe(void)
memset(&sdev, 0, sizeof(sdev)); memset(&sdev, 0, sizeof(sdev));
sdev.reg_addrs[0].phys_addr = sun4_eth_physaddr; sdev.reg_addrs[0].phys_addr = sun4_eth_physaddr;
sdev.irqs[0] = 6; sdev.irqs[0] = 6;
return sparc_lance_init(NULL, &sdev, 0, 0); return sparc_lance_init(&sdev, 0, 0);
} }
return -ENODEV; return -ENODEV;
} }
...@@ -1555,7 +1551,6 @@ static int __init sparc_lance_probe(void) ...@@ -1555,7 +1551,6 @@ static int __init sparc_lance_probe(void)
{ {
struct sbus_bus *bus; struct sbus_bus *bus;
struct sbus_dev *sdev = 0; struct sbus_dev *sdev = 0;
struct net_device *dev = NULL;
struct sbus_dma *ledma = 0; struct sbus_dma *ledma = 0;
static int called; static int called;
int cards = 0, v; int cards = 0, v;
...@@ -1568,25 +1563,23 @@ static int __init sparc_lance_probe(void) ...@@ -1568,25 +1563,23 @@ static int __init sparc_lance_probe(void)
for_each_sbus (bus) { for_each_sbus (bus) {
for_each_sbusdev (sdev, bus) { for_each_sbusdev (sdev, bus) {
if (cards)
dev = NULL;
if (strcmp(sdev->prom_name, "le") == 0) { if (strcmp(sdev->prom_name, "le") == 0) {
cards++; cards++;
if ((v = sparc_lance_init(dev, sdev, 0, 0))) if ((v = sparc_lance_init(sdev, 0, 0)))
return v; return v;
continue; continue;
} }
if (strcmp(sdev->prom_name, "ledma") == 0) { if (strcmp(sdev->prom_name, "ledma") == 0) {
cards++; cards++;
ledma = find_ledma(sdev); ledma = find_ledma(sdev);
if ((v = sparc_lance_init(dev, sdev->child, if ((v = sparc_lance_init(sdev->child,
ledma, 0))) ledma, 0)))
return v; return v;
continue; continue;
} }
if (strcmp(sdev->prom_name, "lebuffer") == 0){ if (strcmp(sdev->prom_name, "lebuffer") == 0){
cards++; cards++;
if ((v = sparc_lance_init(dev, sdev->child, if ((v = sparc_lance_init(sdev->child,
0, sdev))) 0, sdev)))
return v; return v;
continue; continue;
......
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