clean up etehrnet driver

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@11389 3c298f89-4303-0410-b956-a3cf2f4a3e73
master
John Crispin 2008-06-07 10:12:15 +00:00
parent 2bc5f0524a
commit 8e893e4488
2 changed files with 26 additions and 29 deletions

View File

@ -49,7 +49,7 @@
#define DRVNAME "ifxmips_mii0" #define DRVNAME "ifxmips_mii0"
static struct net_device ifxmips_mii0_dev; static struct net_device *ifxmips_mii0_dev;
static unsigned char u_boot_ethaddr[MAX_ADDR_LEN]; static unsigned char u_boot_ethaddr[MAX_ADDR_LEN];
void void
@ -233,12 +233,12 @@ dma_intr_handler (struct dma_device_info* dma_dev, int status)
switch (status) switch (status)
{ {
case RCV_INT: case RCV_INT:
switch_hw_receive(&ifxmips_mii0_dev, dma_dev); switch_hw_receive(ifxmips_mii0_dev, dma_dev);
break; break;
case TX_BUF_FULL_INT: case TX_BUF_FULL_INT:
printk(KERN_INFO DRVNAME ": tx buffer full\n"); printk(KERN_INFO DRVNAME ": tx buffer full\n");
netif_stop_queue(&ifxmips_mii0_dev); netif_stop_queue(ifxmips_mii0_dev);
for (i = 0; i < dma_dev->max_tx_chan_num; i++) for (i = 0; i < dma_dev->max_tx_chan_num; i++)
{ {
if ((dma_dev->tx_chan[i])->control==IFXMIPS_DMA_CH_ON) if ((dma_dev->tx_chan[i])->control==IFXMIPS_DMA_CH_ON)
@ -250,7 +250,7 @@ dma_intr_handler (struct dma_device_info* dma_dev, int status)
for (i = 0; i < dma_dev->max_tx_chan_num; i++) for (i = 0; i < dma_dev->max_tx_chan_num; i++)
dma_dev->tx_chan[i]->disable_irq(dma_dev->tx_chan[i]); dma_dev->tx_chan[i]->disable_irq(dma_dev->tx_chan[i]);
netif_wake_queue(&ifxmips_mii0_dev); netif_wake_queue(ifxmips_mii0_dev);
break; break;
} }
@ -312,10 +312,6 @@ switch_init (struct net_device *dev)
dev->get_stats = ifxmips_get_stats; dev->get_stats = ifxmips_get_stats;
dev->tx_timeout = switch_tx_timeout; dev->tx_timeout = switch_tx_timeout;
dev->watchdog_timeo = 10 * HZ; dev->watchdog_timeo = 10 * HZ;
dev->priv = kmalloc(sizeof(struct switch_priv), GFP_KERNEL);
if (dev->priv == NULL)
return -ENOMEM;
memset(dev->priv, 0, sizeof(struct switch_priv)); memset(dev->priv, 0, sizeof(struct switch_priv));
priv = dev->priv; priv = dev->priv;
@ -394,15 +390,16 @@ ifxmips_mii_probe(struct platform_device *dev)
{ {
int result = 0; int result = 0;
ifxmips_mii0_dev.init = switch_init; ifxmips_mii0_dev = alloc_etherdev(sizeof(struct switch_priv));
strcpy(ifxmips_mii0_dev.name, "eth%d"); ifxmips_mii0_dev->init = switch_init;
SET_MODULE_OWNER(dev);
result = register_netdev(&ifxmips_mii0_dev); strcpy(ifxmips_mii0_dev->name, "eth%d");
result = register_netdev(ifxmips_mii0_dev);
if (result) if (result)
{ {
printk(KERN_INFO DRVNAME ": error %i registering device \"%s\"\n", result, ifxmips_mii0_dev.name); printk(KERN_INFO DRVNAME ": error %i registering device \"%s\"\n", result, ifxmips_mii0_dev->name);
goto out; goto out;
} }
@ -417,37 +414,37 @@ out:
static int static int
ifxmips_mii_remove(struct platform_device *dev) ifxmips_mii_remove(struct platform_device *dev)
{ {
struct switch_priv *priv = (struct switch_priv*)ifxmips_mii0_dev.priv; struct switch_priv *priv = (struct switch_priv*)ifxmips_mii0_dev->priv;
printk(KERN_INFO DRVNAME ": ifxmips_mii0 cleanup\n"); printk(KERN_INFO DRVNAME ": ifxmips_mii0 cleanup\n");
dma_device_unregister(priv->dma_device); dma_device_unregister(priv->dma_device);
dma_device_release(priv->dma_device); dma_device_release(priv->dma_device);
kfree(priv->dma_device); kfree(priv->dma_device);
kfree(ifxmips_mii0_dev.priv); kfree(ifxmips_mii0_dev->priv);
unregister_netdev(&ifxmips_mii0_dev); unregister_netdev(ifxmips_mii0_dev);
return 0; return 0;
} }
static struct static struct
platform_driver ifxmips_mii_driver = { platform_driver ifxmips_mii_driver = {
.probe = ifxmips_mii_probe, .probe = ifxmips_mii_probe,
.remove = ifxmips_mii_remove, .remove = ifxmips_mii_remove,
.driver = { .driver = {
.name = DRVNAME, .name = DRVNAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
}; };
int __init int __init
ifxmips_mii_init(void) ifxmips_mii_init(void)
{ {
int ret = platform_driver_register(&ifxmips_mii_driver); int ret = platform_driver_register(&ifxmips_mii_driver);
if (ret) if (ret)
printk(KERN_INFO DRVNAME ": Error registering platfom driver!"); printk(KERN_INFO DRVNAME ": Error registering platfom driver!");
return ret; return ret;
} }
static void __exit static void __exit

View File

@ -90,4 +90,4 @@ Index: linux-2.6.25.4/drivers/net/Makefile
obj-$(CONFIG_NETXEN_NIC) += netxen/ obj-$(CONFIG_NETXEN_NIC) += netxen/
obj-$(CONFIG_NIU) += niu.o obj-$(CONFIG_NIU) += niu.o
obj-$(CONFIG_VIRTIO_NET) += virtio_net.o obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
+obj-$(CONFIG_IFXMIPS_MII0) += drivers/net/ifxmips_mii0.o +obj-$(CONFIG_IFXMIPS_MII0) += ifxmips_mii0.o