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