Commit 8184914d authored by David S. Miller's avatar David S. Miller

Merge nuts.ninka.net:/home/davem/src/BK/network-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 9be2217a 78cf0a67
...@@ -292,37 +292,19 @@ static void e100_set_network_leds(int active); ...@@ -292,37 +292,19 @@ static void e100_set_network_leds(int active);
*/ */
static int __init static int __init
etrax_ethernet_init(struct net_device *dev) etrax_ethernet_init(void)
{ {
int i; struct net_device *dev;
int i, err;
int anOffset = 0; int anOffset = 0;
printk("ETRAX 100LX 10/100MBit ethernet v2.0 (c) 2000-2001 Axis Communications AB\n"); printk("ETRAX 100LX 10/100MBit ethernet v2.0 (c) 2000-2001 Axis Communications AB\n");
dev->base_addr = (unsigned int)R_NETWORK_SA_0; /* just to have something to show */ dev = alloc_etherdev(sizeof(struct net_local));
printk("%s initialized\n", dev->name);
/* make Linux aware of the new hardware */
if (!dev) {
printk(KERN_WARNING "%s: dev == NULL. Should this happen?\n",
cardname);
dev = init_etherdev(dev, sizeof(struct net_local));
if (!dev) if (!dev)
panic("init_etherdev failed\n");
}
/* setup generic handlers and stuff in the dev struct */
ether_setup(dev);
/* make room for the local structure containing stats etc */
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev->priv == NULL)
return -ENOMEM; return -ENOMEM;
memset(dev->priv, 0, sizeof(struct net_local));
dev->base_addr = (unsigned int)R_NETWORK_SA_0; /* just to have something to show */
/* now setup our etrax specific stuff */ /* now setup our etrax specific stuff */
...@@ -340,10 +322,6 @@ etrax_ethernet_init(struct net_device *dev) ...@@ -340,10 +322,6 @@ etrax_ethernet_init(struct net_device *dev)
dev->do_ioctl = e100_ioctl; dev->do_ioctl = e100_ioctl;
dev->tx_timeout = e100_tx_timeout; dev->tx_timeout = e100_tx_timeout;
/* set the default MAC address */
e100_set_mac_address(dev, &default_mac);
/* Initialise the list of Etrax DMA-descriptors */ /* Initialise the list of Etrax DMA-descriptors */
/* Initialise receive descriptors */ /* Initialise receive descriptors */
...@@ -371,6 +349,16 @@ etrax_ethernet_init(struct net_device *dev) ...@@ -371,6 +349,16 @@ etrax_ethernet_init(struct net_device *dev)
myLastRxDesc = &RxDescList[NBR_OF_RX_DESC - 1]; myLastRxDesc = &RxDescList[NBR_OF_RX_DESC - 1];
myPrevRxDesc = &RxDescList[NBR_OF_RX_DESC - 1]; myPrevRxDesc = &RxDescList[NBR_OF_RX_DESC - 1];
err = register_netdev(dev);
if (err) {
kfree(dev);
return err;
}
/* set the default MAC address */
e100_set_mac_address(dev, &default_mac);
/* Initialize speed indicator stuff. */ /* Initialize speed indicator stuff. */
current_speed = 10; current_speed = 10;
...@@ -1349,19 +1337,10 @@ e100_set_network_leds(int active) ...@@ -1349,19 +1337,10 @@ e100_set_network_leds(int active)
} }
} }
static struct net_device dev_etrax_ethernet; /* only got one */
static int static int
etrax_init_module(void) etrax_init_module(void)
{ {
struct net_device *d = &dev_etrax_ethernet; return etrax_ethernet_init();
d->init = etrax_ethernet_init;
if (register_netdev(d) == 0)
return 0;
else
return -ENODEV;
} }
module_init(etrax_init_module); module_init(etrax_init_module);
...@@ -162,37 +162,19 @@ extern unsigned char e100lpslaveprog; ...@@ -162,37 +162,19 @@ extern unsigned char e100lpslaveprog;
* (detachable devices only). * (detachable devices only).
*/ */
static int __init static int __init
etrax_ethernet_lpslave_init(struct net_device *dev) etrax_ethernet_lpslave_init(void)
{ {
int i; struct net_device *dev;
int i, err;
int anOffset = 0; int anOffset = 0;
printk("Etrax/100 lpslave ethernet driver v0.3, (c) 1999 Axis Communications AB\n"); printk("Etrax/100 lpslave ethernet driver v0.3, (c) 1999 Axis Communications AB\n");
dev->base_addr = 2; dev = alloc_etherdev(sizeof(struct net_lock));
printk("%s initialized\n", dev->name);
/* make Linux aware of the new hardware */
if (!dev) {
printk(KERN_WARNING "%s: dev == NULL. Should this happen?\n",
cardname);
dev = init_etherdev(dev, sizeof(struct net_local));
if (!dev) if (!dev)
panic("init_etherdev failed\n");
}
/* setup generic handlers and stuff in the dev struct */
ether_setup(dev);
/* make room for the local structure containing stats etc */
dev->priv = kmalloc(sizeof(struct net_local), GFP_KERNEL);
if (dev->priv == NULL)
return -ENOMEM; return -ENOMEM;
memset(dev->priv, 0, sizeof(struct net_local));
dev->base_addr = 2;
/* now setup our etrax specific stuff */ /* now setup our etrax specific stuff */
...@@ -242,7 +224,11 @@ etrax_ethernet_lpslave_init(struct net_device *dev) ...@@ -242,7 +224,11 @@ etrax_ethernet_lpslave_init(struct net_device *dev)
TxDescList[0].buf = virt_to_phys(&host_command); TxDescList[0].buf = virt_to_phys(&host_command);
TxDescList[0].next = virt_to_phys(&TxDescList[1]); TxDescList[0].next = virt_to_phys(&TxDescList[1]);
return 0; err = register_netdev(dev);
if (err)
kfree(dev);
return err;
} }
/* set MAC address of the interface. called from the core after a /* set MAC address of the interface. called from the core after a
...@@ -1017,19 +1003,10 @@ dump_parport_status(void) ...@@ -1017,19 +1003,10 @@ dump_parport_status(void)
} }
#endif /* ETHDEBUG */ #endif /* ETHDEBUG */
static struct net_device dev_etrax_slave_ethernet;
static int static int
etrax_init_module(void) etrax_init_module(void)
{ {
struct net_device *d = &dev_etrax_slave_ethernet; return etrax_ethernet_lpslave_init();
d->init = etrax_ethernet_lpslave_init;
if(register_netdev(d) == 0)
return 0;
else
return -ENODEV;
} }
module_init(etrax_init_module); module_init(etrax_init_module);
...@@ -191,7 +191,7 @@ simeth_probe1(void) ...@@ -191,7 +191,7 @@ simeth_probe1(void)
unsigned char mac_addr[ETH_ALEN]; unsigned char mac_addr[ETH_ALEN];
struct simeth_local *local; struct simeth_local *local;
struct net_device *dev; struct net_device *dev;
int fd, i; int fd, i, err;
/* /*
* XXX Fix me * XXX Fix me
...@@ -207,22 +207,12 @@ simeth_probe1(void) ...@@ -207,22 +207,12 @@ simeth_probe1(void)
if (fd == -1) if (fd == -1)
return -ENODEV; return -ENODEV;
dev = init_etherdev(NULL, sizeof(struct simeth_local)); dev = alloc_etherdev(sizeof(struct simeth_local));
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
memcpy(dev->dev_addr, mac_addr, sizeof(mac_addr)); memcpy(dev->dev_addr, mac_addr, sizeof(mac_addr));
dev->irq = ia64_alloc_vector();
/*
* attach the interrupt in the simulator, this does enable interrupts
* until a netdev_attach() is called
*/
netdev_connect(dev->irq);
memset(dev->priv, 0, sizeof(struct simeth_local));
local = dev->priv; local = dev->priv;
local->simfd = fd; /* keep track of underlying file descriptor */ local->simfd = fd; /* keep track of underlying file descriptor */
...@@ -232,8 +222,19 @@ simeth_probe1(void) ...@@ -232,8 +222,19 @@ simeth_probe1(void)
dev->get_stats = simeth_get_stats; dev->get_stats = simeth_get_stats;
dev->set_multicast_list = set_multicast_list; /* no yet used */ dev->set_multicast_list = set_multicast_list; /* no yet used */
/* Fill in the fields of the device structure with ethernet-generic values. */ err = register_netdev(dev);
ether_setup(dev); if (dev) {
kfree(dev);
return err;
}
dev->irq = ia64_alloc_vector();
/*
* attach the interrupt in the simulator, this does enable interrupts
* until a netdev_attach() is called
*/
netdev_connect(dev->irq);
printk(KERN_INFO "%s: hosteth=%s simfd=%d, HwAddr", printk(KERN_INFO "%s: hosteth=%s simfd=%d, HwAddr",
dev->name, simeth_device, local->simfd); dev->name, simeth_device, local->simfd);
......
...@@ -630,19 +630,15 @@ int __init scc_enet_init(void) ...@@ -630,19 +630,15 @@ 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 @@ int __init scc_enet_init(void) ...@@ -771,6 +767,7 @@ 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 @@ int __init scc_enet_init(void) ...@@ -808,6 +805,7 @@ 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 @@ int __init scc_enet_init(void) ...@@ -837,7 +835,6 @@ 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 @@ int __init scc_enet_init(void) ...@@ -852,6 +849,12 @@ 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 @@ int __init fec_enet_init(void) ...@@ -1328,7 +1328,7 @@ 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 @@ int __init fec_enet_init(void) ...@@ -1339,23 +1339,16 @@ 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 @@ int __init fec_enet_init(void) ...@@ -1376,6 +1369,12 @@ 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 @@ int __init scc_enet_init(void) ...@@ -643,7 +643,7 @@ 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 @@ int __init scc_enet_init(void) ...@@ -659,19 +659,13 @@ 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 @@ int __init scc_enet_init(void) ...@@ -841,6 +835,7 @@ 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 @@ int __init scc_enet_init(void) ...@@ -939,7 +934,6 @@ 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 @@ int __init scc_enet_init(void) ...@@ -953,6 +947,12 @@ 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 @@ int __init fec_enet_init(void) ...@@ -1570,7 +1570,7 @@ 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 @@ int __init fec_enet_init(void) ...@@ -1586,17 +1586,11 @@ 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 @@ int __init fec_enet_init(void) ...@@ -1661,6 +1655,7 @@ 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 @@ int __init fec_enet_init(void) ...@@ -1715,7 +1710,6 @@ 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 @@ int __init fec_enet_init(void) ...@@ -1752,6 +1746,12 @@ 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"
......
...@@ -1331,12 +1331,13 @@ static void __init bmac_probe1(struct device_node *bmac, int is_bmac_plus) ...@@ -1331,12 +1331,13 @@ static void __init bmac_probe1(struct device_node *bmac, int is_bmac_plus)
} }
} }
dev = init_etherdev(NULL, PRIV_BYTES); dev = alloc_etherdev(PRIV_BYTES);
if (!dev) { if (!dev) {
printk(KERN_ERR "init_etherdev failed, out of memory for BMAC %s\n", printk(KERN_ERR "alloc_etherdev failed, out of memory for BMAC %s\n",
bmac->full_name); bmac->full_name);
return; return;
} }
bp = (struct bmac_data *) dev->priv; bp = (struct bmac_data *) dev->priv;
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
bp->node = bmac; bp->node = bmac;
...@@ -1344,21 +1345,22 @@ static void __init bmac_probe1(struct device_node *bmac, int is_bmac_plus) ...@@ -1344,21 +1345,22 @@ static void __init bmac_probe1(struct device_node *bmac, int is_bmac_plus)
if (!request_OF_resource(bmac, 0, " (bmac)")) { if (!request_OF_resource(bmac, 0, " (bmac)")) {
printk(KERN_ERR "BMAC: can't request IO resource !\n"); printk(KERN_ERR "BMAC: can't request IO resource !\n");
goto err_out; goto out1;
} }
if (!request_OF_resource(bmac, 1, " (bmac tx dma)")) { if (!request_OF_resource(bmac, 1, " (bmac tx dma)")) {
printk(KERN_ERR "BMAC: can't request TX DMA resource !\n"); printk(KERN_ERR "BMAC: can't request TX DMA resource !\n");
goto err_out; goto out2;
} }
if (!request_OF_resource(bmac, 2, " (bmac rx dma)")) { if (!request_OF_resource(bmac, 2, " (bmac rx dma)")) {
printk(KERN_ERR "BMAC: can't request RX DMA resource !\n"); printk(KERN_ERR "BMAC: can't request RX DMA resource !\n");
goto err_out; goto out3;
} }
dev->base_addr = (unsigned long) dev->base_addr = (unsigned long)
ioremap(bmac->addrs[0].address, bmac->addrs[0].size); ioremap(bmac->addrs[0].address, bmac->addrs[0].size);
if (!dev->base_addr) if (!dev->base_addr)
goto err_out; goto out4;
dev->irq = bmac->intrs[0].line; dev->irq = bmac->intrs[0].line;
bmac_enable_and_reset_chip(dev); bmac_enable_and_reset_chip(dev);
...@@ -1430,10 +1432,18 @@ static void __init bmac_probe1(struct device_node *bmac, int is_bmac_plus) ...@@ -1430,10 +1432,18 @@ static void __init bmac_probe1(struct device_node *bmac, int is_bmac_plus)
disable_irq(dev->irq); disable_irq(dev->irq);
pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 0); pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 0);
if (register_netdev(dev) != 0) {
printk(KERN_ERR "registration failed for BMAC %s\n",
bmac->full_name);
goto err_out_irq2;
}
bp->next_bmac = bmac_devs; bp->next_bmac = bmac_devs;
bmac_devs = dev; bmac_devs = dev;
return; return;
err_out_irq2:
free_irq(bmac->intrs[2].line, dev);
err_out_irq1: err_out_irq1:
free_irq(bmac->intrs[1].line, dev); free_irq(bmac->intrs[1].line, dev);
err_out_irq0: err_out_irq0:
...@@ -1444,14 +1454,14 @@ static void __init bmac_probe1(struct device_node *bmac, int is_bmac_plus) ...@@ -1444,14 +1454,14 @@ static void __init bmac_probe1(struct device_node *bmac, int is_bmac_plus)
iounmap((void *)bp->tx_dma); iounmap((void *)bp->tx_dma);
err_out_iounmap: err_out_iounmap:
iounmap((void *)dev->base_addr); iounmap((void *)dev->base_addr);
err_out: out4:
if (bp->node) {
release_OF_resource(bp->node, 0);
release_OF_resource(bp->node, 1);
release_OF_resource(bp->node, 2); release_OF_resource(bp->node, 2);
out3:
release_OF_resource(bp->node, 1);
out2:
release_OF_resource(bp->node, 0);
out1:
pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 0); pmac_call_feature(PMAC_FTR_BMAC_ENABLE, bp->node, 0, 0);
}
unregister_netdev(dev);
kfree(dev); kfree(dev);
} }
......
...@@ -329,6 +329,12 @@ static void ax_bump(struct ax_disp *ax) ...@@ -329,6 +329,12 @@ static void ax_bump(struct ax_disp *ax)
return; return;
} }
ax->rcount -= 2; ax->rcount -= 2;
/* dl9sau bugfix: the trailling two bytes flexnet crc
* will not be passed to the kernel. thus we have
* to correct the kissparm signature, because it
* indicates a crc but there's none
*/
*ax->rbuff &= ~0x20;
} }
} }
......
...@@ -722,34 +722,31 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev) ...@@ -722,34 +722,31 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev)
struct net_device *qe_devs[4]; struct net_device *qe_devs[4];
struct sunqe *qeps[4]; struct sunqe *qeps[4];
struct sbus_dev *qesdevs[4]; struct sbus_dev *qesdevs[4];
struct sbus_dev *child;
struct sunqec *qecp = NULL; struct sunqec *qecp = NULL;
u8 bsizes, bsizes_more; u8 bsizes, bsizes_more;
int i, j, res = ENOMEM; int i, j, res = -ENOMEM;
dev = init_etherdev(0, sizeof(struct sunqe)); for (i = 0; i < 4; i++) {
qe_devs[0] = dev; qe_devs[i] = alloc_etherdev(sizeof(struct sunqe));
qeps[0] = (struct sunqe *) dev->priv; if (!qe_devs[i])
qeps[0]->channel = 0; goto out;
spin_lock_init(&qeps[0]->lock); }
for (j = 0; j < 6; j++)
qe_devs[0]->dev_addr[j] = idprom->id_ethaddr[j];
if (version_printed++ == 0) if (version_printed++ == 0)
printk(KERN_INFO "%s", version); printk(KERN_INFO "%s", version);
qe_devs[1] = qe_devs[2] = qe_devs[3] = NULL; for (i = 0; i < 4; i++) {
for (i = 1; i < 4; i++) {
qe_devs[i] = init_etherdev(0, sizeof(struct sunqe));
if (qe_devs[i] == NULL || qe_devs[i]->priv == NULL)
goto qec_free_devs;
qeps[i] = (struct sunqe *) qe_devs[i]->priv; qeps[i] = (struct sunqe *) qe_devs[i]->priv;
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
qe_devs[i]->dev_addr[j] = idprom->id_ethaddr[j]; qe_devs[i]->dev_addr[j] = idprom->id_ethaddr[j];
qeps[i]->channel = i; qeps[i]->channel = i;
spin_lock_init(&qeps[i]->lock);
} }
qecp = kmalloc(sizeof(struct sunqec), GFP_KERNEL); qecp = kmalloc(sizeof(struct sunqec), GFP_KERNEL);
if (qecp == NULL) if (qecp == NULL)
goto qec_free_devs; goto out1;
qecp->qec_sdev = sdev; qecp->qec_sdev = sdev;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
...@@ -758,25 +755,15 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev) ...@@ -758,25 +755,15 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev)
qeps[i]->parent = qecp; qeps[i]->parent = qecp;
} }
/* Link in channel 0. */ res = -ENODEV;
i = prom_getintdefault(sdev->child->prom_node, "channel#", -1);
if (i == -1) { res=ENODEV; goto qec_free_devs; }
qesdevs[i] = sdev->child;
/* Link in channel 1. */
i = prom_getintdefault(sdev->child->next->prom_node, "channel#", -1);
if (i == -1) { res=ENODEV; goto qec_free_devs; }
qesdevs[i] = sdev->child->next;
/* Link in channel 2. */
i = prom_getintdefault(sdev->child->next->next->prom_node, "channel#", -1);
if (i == -1) { res=ENODEV; goto qec_free_devs; }
qesdevs[i] = sdev->child->next->next;
/* Link in channel 3. */ for (i = 0, child = sdev->child; i < 4; i++, child = child->next) {
i = prom_getintdefault(sdev->child->next->next->next->prom_node, "channel#", -1); /* Link in channel */
if (i == -1) { res=ENODEV; goto qec_free_devs; } j = prom_getintdefault(child->prom_node, "channel#", -1);
qesdevs[i] = sdev->child->next->next->next; if (j == -1)
goto out2;
qesdevs[j] = child;
}
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
qeps[i]->qe_sdev = qesdevs[i]; qeps[i]->qe_sdev = qesdevs[i];
...@@ -786,22 +773,18 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev) ...@@ -786,22 +773,18 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev)
GLOB_REG_SIZE, "QEC Global Registers"); GLOB_REG_SIZE, "QEC Global Registers");
if (!qecp->gregs) { if (!qecp->gregs) {
printk(KERN_ERR "QuadEther: Cannot map QEC global registers.\n"); printk(KERN_ERR "QuadEther: Cannot map QEC global registers.\n");
res = ENODEV; goto out2;
goto qec_free_devs;
} }
/* Make sure the QEC is in MACE mode. */ /* Make sure the QEC is in MACE mode. */
if ((sbus_readl(qecp->gregs + GLOB_CTRL) & 0xf0000000) != GLOB_CTRL_MMODE) { if ((sbus_readl(qecp->gregs + GLOB_CTRL) & 0xf0000000) != GLOB_CTRL_MMODE) {
printk(KERN_ERR "QuadEther: AIEEE, QEC is not in MACE mode!\n"); printk(KERN_ERR "QuadEther: AIEEE, QEC is not in MACE mode!\n");
res = ENODEV; goto out3;
goto qec_free_devs;
} }
/* Reset the QEC. */ /* Reset the QEC. */
if (qec_global_reset(qecp->gregs)) { if (qec_global_reset(qecp->gregs))
res = ENODEV; goto out3;
goto qec_free_devs;
}
/* Find and set the burst sizes for the QEC, since it does /* Find and set the burst sizes for the QEC, since it does
* the actual dma for all 4 channels. * the actual dma for all 4 channels.
...@@ -824,40 +807,36 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev) ...@@ -824,40 +807,36 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev)
qec_init_once(qecp, sdev); qec_init_once(qecp, sdev);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
struct sunqe *qe = qeps[i];
/* Map in QEC per-channel control registers. */ /* Map in QEC per-channel control registers. */
qeps[i]->qcregs = sbus_ioremap(&qesdevs[i]->resource[0], 0, qe->qcregs = sbus_ioremap(&qe->qe_sdev->resource[0], 0,
CREG_REG_SIZE, "QEC Channel Registers"); CREG_REG_SIZE, "QEC Channel Registers");
if (!qeps[i]->qcregs) { if (!qe->qcregs) {
printk(KERN_ERR "QuadEther: Cannot map QE %d's channel registers.\n", i); printk(KERN_ERR "QuadEther: Cannot map QE %d's channel registers.\n", i);
res = ENODEV; goto out4;
goto qec_free_devs;
} }
/* Map in per-channel AMD MACE registers. */ /* Map in per-channel AMD MACE registers. */
qeps[i]->mregs = sbus_ioremap(&qesdevs[i]->resource[1], 0, qe->mregs = sbus_ioremap(&qe->qe_sdev->resource[1], 0,
MREGS_REG_SIZE, "QE MACE Registers"); MREGS_REG_SIZE, "QE MACE Registers");
if (!qeps[i]->mregs) { if (!qe->mregs) {
printk(KERN_ERR "QuadEther: Cannot map QE %d's MACE registers.\n", i); printk(KERN_ERR "QuadEther: Cannot map QE %d's MACE registers.\n", i);
res = ENODEV; goto out4;
goto qec_free_devs;
} }
qeps[i]->qe_block = sbus_alloc_consistent(qesdevs[i], qe->qe_block = sbus_alloc_consistent(qe->qe_sdev,
PAGE_SIZE, PAGE_SIZE,
&qeps[i]->qblock_dvma); &qe->qblock_dvma);
qeps[i]->buffers = sbus_alloc_consistent(qesdevs[i], qe->buffers = sbus_alloc_consistent(qe->qe_sdev,
sizeof(struct sunqe_buffers), sizeof(struct sunqe_buffers),
&qeps[i]->buffers_dvma); &qe->buffers_dvma);
if (qeps[i]->qe_block == NULL || if (qe->qe_block == NULL || qe->qblock_dvma == 0 ||
qeps[i]->qblock_dvma == 0 || qe->buffers == NULL || qe->buffers_dvma == 0) {
qeps[i]->buffers == NULL || goto out4;
qeps[i]->buffers_dvma == 0) {
res = ENODEV;
goto qec_free_devs;
} }
/* Stop this QE. */ /* Stop this QE. */
qe_stop(qeps[i]); qe_stop(qe);
} }
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
...@@ -871,7 +850,6 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev) ...@@ -871,7 +850,6 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev)
qe_devs[i]->watchdog_timeo = 5*HZ; qe_devs[i]->watchdog_timeo = 5*HZ;
qe_devs[i]->irq = sdev->irqs[0]; qe_devs[i]->irq = sdev->irqs[0];
qe_devs[i]->dma = 0; qe_devs[i]->dma = 0;
ether_setup(qe_devs[i]);
} }
/* QEC receives interrupts from each QE, then it sends the actual /* QEC receives interrupts from each QE, then it sends the actual
...@@ -882,8 +860,13 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev) ...@@ -882,8 +860,13 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev)
if (request_irq(sdev->irqs[0], &qec_interrupt, if (request_irq(sdev->irqs[0], &qec_interrupt,
SA_SHIRQ, "QuadEther", (void *) qecp)) { SA_SHIRQ, "QuadEther", (void *) qecp)) {
printk(KERN_ERR "QuadEther: Can't register QEC master irq handler.\n"); printk(KERN_ERR "QuadEther: Can't register QEC master irq handler.\n");
res = EAGAIN; res = -EAGAIN;
goto qec_free_devs; goto out4;
}
for (i = 0; i < 4; i++) {
if (register_netdev(qe_devs[i]) != 0)
goto out5;
} }
/* Report the QE channels. */ /* Report the QE channels. */
...@@ -899,42 +882,43 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev) ...@@ -899,42 +882,43 @@ static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev)
/* We are home free at this point, link the qe's into /* We are home free at this point, link the qe's into
* the master list for later driver exit. * the master list for later driver exit.
*/ */
for (i = 0; i < 4; i++)
qe_devs[i]->ifindex = dev_new_index();
qecp->next_module = root_qec_dev; qecp->next_module = root_qec_dev;
root_qec_dev = qecp; root_qec_dev = qecp;
return 0; return 0;
qec_free_devs: out5:
while (i--)
unregister_netdev(qe_devs[i]);
free_irq(sdev->irqs[0], (void *)qecp);
out4:
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (qe_devs[i] != NULL) {
if (qe_devs[i]->priv) {
struct sunqe *qe = (struct sunqe *)qe_devs[i]->priv; struct sunqe *qe = (struct sunqe *)qe_devs[i]->priv;
if (qe->qcregs) if (qe->qcregs)
sbus_iounmap(qe->qcregs, CREG_REG_SIZE); sbus_iounmap(qe->qcregs, CREG_REG_SIZE);
if (qe->mregs) if (qe->mregs)
sbus_iounmap(qe->mregs, MREGS_REG_SIZE); sbus_iounmap(qe->mregs, MREGS_REG_SIZE);
if (qe->qe_block != NULL) if (qe->qe_block)
sbus_free_consistent(qe->qe_sdev, sbus_free_consistent(qe->qe_sdev,
PAGE_SIZE, PAGE_SIZE,
qe->qe_block, qe->qe_block,
qe->qblock_dvma); qe->qblock_dvma);
if (qe->buffers != NULL) if (qe->buffers)
sbus_free_consistent(qe->qe_sdev, sbus_free_consistent(qe->qe_sdev,
sizeof(struct sunqe_buffers), sizeof(struct sunqe_buffers),
qe->buffers, qe->buffers,
qe->buffers_dvma); qe->buffers_dvma);
} }
kfree(qe_devs[i]); out3:
}
}
if (qecp != NULL) {
if (qecp->gregs)
sbus_iounmap(qecp->gregs, GLOB_REG_SIZE); sbus_iounmap(qecp->gregs, GLOB_REG_SIZE);
out2:
kfree(qecp); kfree(qecp);
} out1:
i = 4;
out:
while (i--)
kfree(qe_devs[i]);
return res; return res;
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/pfkeyv2.h> #include <linux/pfkeyv2.h>
#include <linux/in6.h> #include <linux/in6.h>
#include <linux/slab.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/dst.h> #include <net/dst.h>
......
...@@ -154,9 +154,15 @@ int ax25_rebuild_header(struct sk_buff *skb) ...@@ -154,9 +154,15 @@ int ax25_rebuild_header(struct sk_buff *skb)
skb_set_owner_w(ourskb, skb->sk); skb_set_owner_w(ourskb, skb->sk);
kfree_skb(skb); kfree_skb(skb);
/* dl9sau: bugfix
src_c = *src; * after kfree_skb(), dst and src which were pointer
dst_c = *dst; * to bp which is part of skb->data would not be valid
* anymore hope that after skb_pull(ourskb, ..) our
* dsc_c and src_c will not become invalid
*/
bp = ourskb->data;
dst_c = *(ax25_address *)(bp + 1);
src_c = *(ax25_address *)(bp + 8);
skb_pull(ourskb, AX25_HEADER_LEN - 1); /* Keep PID */ skb_pull(ourskb, AX25_HEADER_LEN - 1); /* Keep PID */
ourskb->nh.raw = ourskb->data; ourskb->nh.raw = ourskb->data;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h>
#include <net/flow.h> #include <net/flow.h>
#include <asm/atomic.h> #include <asm/atomic.h>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* *
*/ */
#include <linux/slab.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/xfrm.h> #include <net/xfrm.h>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/slab.h>
#include <net/xfrm.h> #include <net/xfrm.h>
#include <net/ip.h> #include <net/ip.h>
......
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