Commit 921a5004 authored by Christoph Hellwig's avatar Christoph Hellwig

[NET]: Fix accidental revert of init_etherdev killing in PPC net drivers.

parent 928880f8
...@@ -630,19 +630,15 @@ static int __init scc_enet_init(void) ...@@ -630,19 +630,15 @@ static int __init scc_enet_init(void)
bd = (bd_t *)__res; bd = (bd_t *)__res;
/* Allocate some private information. /* Create an Ethernet device instance.
*/ */
cep = (struct scc_enet_private *)kmalloc(sizeof(*cep), GFP_KERNEL); dev = alloc_etherdev(sizeof(*cep));
if (cep == NULL) if (!dev)
return -ENOMEM; return -ENOMEM;
__clear_user(cep,sizeof(*cep)); cep = dev->priv;
spin_lock_init(&cep->lock); spin_lock_init(&cep->lock);
/* Create an Ethernet device instance.
*/
dev = init_etherdev(0, 0);
/* Get pointer to SCC area in parameter RAM. /* Get pointer to SCC area in parameter RAM.
*/ */
ep = (scc_enet_t *)(&immap->im_dprambase[PROFF_ENET]); ep = (scc_enet_t *)(&immap->im_dprambase[PROFF_ENET]);
...@@ -771,6 +767,7 @@ static int __init scc_enet_init(void) ...@@ -771,6 +767,7 @@ static int __init scc_enet_init(void)
/* Allocate a page. /* Allocate a page.
*/ */
mem_addr = __get_free_page(GFP_KERNEL); mem_addr = __get_free_page(GFP_KERNEL);
/* BUG: no check for failure */
/* Initialize the BD for every fragment in the page. /* Initialize the BD for every fragment in the page.
*/ */
...@@ -808,6 +805,7 @@ static int __init scc_enet_init(void) ...@@ -808,6 +805,7 @@ static int __init scc_enet_init(void)
/* Install our interrupt handler. /* Install our interrupt handler.
*/ */
request_irq(SIU_INT_ENET, scc_enet_interrupt, 0, "enet", dev); request_irq(SIU_INT_ENET, scc_enet_interrupt, 0, "enet", dev);
/* BUG: no check for failure */
/* Set GSMR_H to enable all normal operating modes. /* Set GSMR_H to enable all normal operating modes.
* Set GSMR_L to enable Ethernet to MC68160. * Set GSMR_L to enable Ethernet to MC68160.
...@@ -837,7 +835,6 @@ static int __init scc_enet_init(void) ...@@ -837,7 +835,6 @@ static int __init scc_enet_init(void)
io->iop_pdatc |= PC_EST8260_ENET_NOTFD; io->iop_pdatc |= PC_EST8260_ENET_NOTFD;
dev->base_addr = (unsigned long)ep; dev->base_addr = (unsigned long)ep;
dev->priv = cep;
/* The CPM Ethernet specific entries in the device structure. */ /* The CPM Ethernet specific entries in the device structure. */
dev->open = scc_enet_open; dev->open = scc_enet_open;
...@@ -852,6 +849,12 @@ static int __init scc_enet_init(void) ...@@ -852,6 +849,12 @@ static int __init scc_enet_init(void)
*/ */
sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT); sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
err = register_netdev(dev);
if (err) {
kfree(dev);
return err;
}
printk("%s: SCC ENET Version 0.1, ", dev->name); printk("%s: SCC ENET Version 0.1, ", dev->name);
for (i=0; i<5; i++) for (i=0; i<5; i++)
printk("%02x:", dev->dev_addr[i]); printk("%02x:", dev->dev_addr[i]);
......
...@@ -1328,7 +1328,7 @@ static int __init fec_enet_init(void) ...@@ -1328,7 +1328,7 @@ static int __init fec_enet_init(void)
struct net_device *dev; struct net_device *dev;
struct fcc_enet_private *cep; struct fcc_enet_private *cep;
fcc_info_t *fip; fcc_info_t *fip;
int i, np; int i, np, err;
volatile immap_t *immap; volatile immap_t *immap;
volatile iop8260_t *io; volatile iop8260_t *io;
...@@ -1339,23 +1339,16 @@ static int __init fec_enet_init(void) ...@@ -1339,23 +1339,16 @@ static int __init fec_enet_init(void)
fip = fcc_ports; fip = fcc_ports;
while (np-- > 0) { while (np-- > 0) {
/* Create an Ethernet device instance.
/* Allocate some private information.
*/ */
cep = (struct fcc_enet_private *) dev = alloc_etherdev(sizeof(*cep));
kmalloc(sizeof(*cep), GFP_KERNEL); if (!dev)
if (cep == NULL)
return -ENOMEM; return -ENOMEM;
__clear_user(cep,sizeof(*cep)); cep = dev->priv;
spin_lock_init(&cep->lock); spin_lock_init(&cep->lock);
cep->fip = fip; cep->fip = fip;
/* Create an Ethernet device instance.
*/
dev = init_etherdev(0, 0);
dev->priv = cep;
init_fcc_shutdown(fip, cep, immap); init_fcc_shutdown(fip, cep, immap);
init_fcc_ioports(fip, io, immap); init_fcc_ioports(fip, io, immap);
init_fcc_param(fip, dev, immap); init_fcc_param(fip, dev, immap);
...@@ -1376,6 +1369,12 @@ static int __init fec_enet_init(void) ...@@ -1376,6 +1369,12 @@ static int __init fec_enet_init(void)
init_fcc_startup(fip, dev); init_fcc_startup(fip, dev);
err = register_netdev(dev);
if (err) {
kfree(dev);
return err;
}
printk("%s: FCC ENET Version 0.3, ", dev->name); printk("%s: FCC ENET Version 0.3, ", dev->name);
for (i=0; i<5; i++) for (i=0; i<5; i++)
printk("%02x:", dev->dev_addr[i]); printk("%02x:", dev->dev_addr[i]);
......
...@@ -643,7 +643,7 @@ static int __init scc_enet_init(void) ...@@ -643,7 +643,7 @@ static int __init scc_enet_init(void)
{ {
struct net_device *dev; struct net_device *dev;
struct scc_enet_private *cep; struct scc_enet_private *cep;
int i, j, k; int i, j, k, err;
unsigned char *eap, *ba; unsigned char *eap, *ba;
dma_addr_t mem_addr; dma_addr_t mem_addr;
bd_t *bd; bd_t *bd;
...@@ -659,19 +659,13 @@ static int __init scc_enet_init(void) ...@@ -659,19 +659,13 @@ static int __init scc_enet_init(void)
bd = (bd_t *)__res; bd = (bd_t *)__res;
/* Allocate some private information. dev = alloc_etherdev(sizeof(*cep));
*/ if (!dev)
cep = (struct scc_enet_private *)kmalloc(sizeof(*cep), GFP_KERNEL);
if (cep == NULL)
return -ENOMEM; return -ENOMEM;
__clear_user(cep,sizeof(*cep)); cep = dev->priv;
spin_lock_init(&cep->lock); spin_lock_init(&cep->lock);
/* Create an Ethernet device instance.
*/
dev = init_etherdev(0, 0);
/* Get pointer to SCC area in parameter RAM. /* Get pointer to SCC area in parameter RAM.
*/ */
ep = (scc_enet_t *)(&cp->cp_dparam[PROFF_ENET]); ep = (scc_enet_t *)(&cp->cp_dparam[PROFF_ENET]);
...@@ -841,6 +835,7 @@ static int __init scc_enet_init(void) ...@@ -841,6 +835,7 @@ static int __init scc_enet_init(void)
/* Allocate a page. /* Allocate a page.
*/ */
ba = (unsigned char *)consistent_alloc(GFP_KERNEL, PAGE_SIZE, &mem_addr); ba = (unsigned char *)consistent_alloc(GFP_KERNEL, PAGE_SIZE, &mem_addr);
/* BUG: no check for failure */
/* Initialize the BD for every fragment in the page. /* Initialize the BD for every fragment in the page.
*/ */
...@@ -939,7 +934,6 @@ static int __init scc_enet_init(void) ...@@ -939,7 +934,6 @@ static int __init scc_enet_init(void)
#endif #endif
dev->base_addr = (unsigned long)ep; dev->base_addr = (unsigned long)ep;
dev->priv = cep;
#if 0 #if 0
dev->name = "CPM_ENET"; dev->name = "CPM_ENET";
#endif #endif
...@@ -953,6 +947,12 @@ static int __init scc_enet_init(void) ...@@ -953,6 +947,12 @@ static int __init scc_enet_init(void)
dev->get_stats = scc_enet_get_stats; dev->get_stats = scc_enet_get_stats;
dev->set_multicast_list = set_multicast_list; dev->set_multicast_list = set_multicast_list;
err = register_netdev(dev);
if (err) {
kfree(dev);
return err;
}
/* And last, enable the transmit and receive processing. /* And last, enable the transmit and receive processing.
*/ */
sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT); sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
......
...@@ -1570,7 +1570,7 @@ static int __init fec_enet_init(void) ...@@ -1570,7 +1570,7 @@ static int __init fec_enet_init(void)
{ {
struct net_device *dev; struct net_device *dev;
struct fec_enet_private *fep; struct fec_enet_private *fep;
int i, j, k; int i, j, k, err;
unsigned char *eap, *iap, *ba; unsigned char *eap, *iap, *ba;
unsigned long mem_addr; unsigned long mem_addr;
volatile cbd_t *bdp; volatile cbd_t *bdp;
...@@ -1586,17 +1586,11 @@ static int __init fec_enet_init(void) ...@@ -1586,17 +1586,11 @@ static int __init fec_enet_init(void)
bd = (bd_t *)__res; bd = (bd_t *)__res;
/* Allocate some private information. dev = alloc_etherdev(sizeof(*fep));
*/ if (!dev)
fep = (struct fec_enet_private *)kmalloc(sizeof(*fep), GFP_KERNEL);
if (fep == NULL)
return -ENOMEM; return -ENOMEM;
__clear_user(fep,sizeof(*fep)); fep = dev->priv;
/* Create an Ethernet device instance.
*/
dev = init_etherdev(0, 0);
fecp = &(immap->im_cpm.cp_fec); fecp = &(immap->im_cpm.cp_fec);
...@@ -1661,6 +1655,7 @@ static int __init fec_enet_init(void) ...@@ -1661,6 +1655,7 @@ static int __init fec_enet_init(void)
/* Allocate a page. /* Allocate a page.
*/ */
ba = (unsigned char *)consistent_alloc(GFP_KERNEL, PAGE_SIZE, &mem_addr); ba = (unsigned char *)consistent_alloc(GFP_KERNEL, PAGE_SIZE, &mem_addr);
/* BUG: no check for failure */
/* Initialize the BD for every fragment in the page. /* Initialize the BD for every fragment in the page.
*/ */
...@@ -1715,7 +1710,6 @@ static int __init fec_enet_init(void) ...@@ -1715,7 +1710,6 @@ static int __init fec_enet_init(void)
#endif #endif
dev->base_addr = (unsigned long)fecp; dev->base_addr = (unsigned long)fecp;
dev->priv = fep;
/* The FEC Ethernet specific entries in the device structure. */ /* The FEC Ethernet specific entries in the device structure. */
dev->open = fec_enet_open; dev->open = fec_enet_open;
...@@ -1752,6 +1746,12 @@ static int __init fec_enet_init(void) ...@@ -1752,6 +1746,12 @@ static int __init fec_enet_init(void)
fecp->fec_mii_speed = 0; /* turn off MDIO */ fecp->fec_mii_speed = 0; /* turn off MDIO */
#endif /* CONFIG_USE_MDIO */ #endif /* CONFIG_USE_MDIO */
err = register_netdev(dev);
if (err) {
kfree(dev);
return err;
}
printk ("%s: FEC ENET Version 0.2, FEC irq %d" printk ("%s: FEC ENET Version 0.2, FEC irq %d"
#ifdef PHY_INTERRUPT #ifdef PHY_INTERRUPT
", MII irq %d" ", MII irq %d"
......
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