Commit d74472f0 authored by Finn Thain's avatar Finn Thain Committed by Linus Torvalds

SONIC: small fix and cleanup

Fix a potential problem in the timeout handling: don't free the DMA buffers
before resetting the chip.

Also a trivial cleanup. Bring macsonic and jazzsonic into sync.
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8b6aaab8
...@@ -269,11 +269,11 @@ static int __devexit jazz_sonic_device_remove (struct platform_device *pdev) ...@@ -269,11 +269,11 @@ static int __devexit jazz_sonic_device_remove (struct platform_device *pdev)
struct net_device *dev = platform_get_drvdata(pdev); struct net_device *dev = platform_get_drvdata(pdev);
struct sonic_local* lp = netdev_priv(dev); struct sonic_local* lp = netdev_priv(dev);
unregister_netdev (dev); unregister_netdev(dev);
dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
lp->descriptors, lp->descriptors_laddr); lp->descriptors, lp->descriptors_laddr);
release_region (dev->base_addr, SONIC_MEM_SIZE); release_region (dev->base_addr, SONIC_MEM_SIZE);
free_netdev (dev); free_netdev(dev);
return 0; return 0;
} }
......
...@@ -522,7 +522,7 @@ int __init mac_nubus_sonic_probe(struct net_device* dev) ...@@ -522,7 +522,7 @@ int __init mac_nubus_sonic_probe(struct net_device* dev)
return macsonic_init(dev); return macsonic_init(dev);
} }
static int __init mac_sonic_probe(struct platform_device *device) static int __init mac_sonic_probe(struct platform_device *pdev)
{ {
struct net_device *dev; struct net_device *dev;
struct sonic_local *lp; struct sonic_local *lp;
...@@ -534,8 +534,8 @@ static int __init mac_sonic_probe(struct platform_device *device) ...@@ -534,8 +534,8 @@ static int __init mac_sonic_probe(struct platform_device *device)
return -ENOMEM; return -ENOMEM;
lp = netdev_priv(dev); lp = netdev_priv(dev);
lp->device = &device->dev; lp->device = &pdev->dev;
SET_NETDEV_DEV(dev, &device->dev); SET_NETDEV_DEV(dev, &pdev->dev);
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
/* This will catch fatal stuff like -ENOMEM as well as success */ /* This will catch fatal stuff like -ENOMEM as well as success */
...@@ -576,15 +576,15 @@ MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)"); ...@@ -576,15 +576,15 @@ MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
#include "sonic.c" #include "sonic.c"
static int __devexit mac_sonic_device_remove (struct platform_device *device) static int __devexit mac_sonic_device_remove (struct platform_device *pdev)
{ {
struct net_device *dev = platform_get_drvdata(device); struct net_device *dev = platform_get_drvdata(pdev);
struct sonic_local* lp = netdev_priv(dev); struct sonic_local* lp = netdev_priv(dev);
unregister_netdev (dev); unregister_netdev(dev);
dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
lp->descriptors, lp->descriptors_laddr); lp->descriptors, lp->descriptors_laddr);
free_netdev (dev); free_netdev(dev);
return 0; return 0;
} }
...@@ -607,9 +607,8 @@ static int __init mac_sonic_init_module(void) ...@@ -607,9 +607,8 @@ static int __init mac_sonic_init_module(void)
} }
mac_sonic_device = platform_device_alloc(mac_sonic_string, 0); mac_sonic_device = platform_device_alloc(mac_sonic_string, 0);
if (!mac_sonic_device) { if (!mac_sonic_device)
goto out_unregister; goto out_unregister;
}
if (platform_device_add(mac_sonic_device)) { if (platform_device_add(mac_sonic_device)) {
platform_device_put(mac_sonic_device); platform_device_put(mac_sonic_device);
......
...@@ -178,8 +178,13 @@ static void sonic_tx_timeout(struct net_device *dev) ...@@ -178,8 +178,13 @@ static void sonic_tx_timeout(struct net_device *dev)
{ {
struct sonic_local *lp = netdev_priv(dev); struct sonic_local *lp = netdev_priv(dev);
int i; int i;
/* Stop the interrupts for this */ /*
* put the Sonic into software-reset mode and
* disable all interrupts before releasing DMA buffers
*/
SONIC_WRITE(SONIC_IMR, 0); SONIC_WRITE(SONIC_IMR, 0);
SONIC_WRITE(SONIC_ISR, 0x7fff);
SONIC_WRITE(SONIC_CMD, SONIC_CR_RST);
/* We could resend the original skbs. Easier to re-initialise. */ /* We could resend the original skbs. Easier to re-initialise. */
for (i = 0; i < SONIC_NUM_TDS; i++) { for (i = 0; i < SONIC_NUM_TDS; i++) {
if(lp->tx_laddr[i]) { if(lp->tx_laddr[i]) {
......
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