X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=drivers%2Fnet%2Fsgiseeq.c;h=2106becf6990c42dbe297753f3aeb07cd12ba1c8;hb=7a627558214664f0e071b2652fc37e4d7d3dce32;hp=f95a5b0223fb9ff8d3ac43737cdadddc15fb5fcf;hpb=86579dd06deecfa6ac88d5e84e4d63c397cd6f6d;p=linux-2.6-omap-h63xx.git diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c index f95a5b0223f..2106becf699 100644 --- a/drivers/net/sgiseeq.c +++ b/drivers/net/sgiseeq.c @@ -12,26 +12,17 @@ #include #include #include -#include -#include -#include -#include #include #include #include #include +#include #include #include -#include -#include -#include -#include -#include -#include #include #include -#include +#include #include "sgiseeq.h" @@ -103,13 +94,9 @@ struct sgiseeq_private { struct net_device_stats stats; - struct net_device *next_module; spinlock_t tx_lock; }; -/* A list of all installed seeq devices, for removing the driver module. */ -static struct net_device *root_sgiseeq_dev; - static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) { hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ; @@ -329,7 +316,6 @@ static inline void sgiseeq_rx(struct net_device *dev, struct sgiseeq_private *sp skb = dev_alloc_skb(len + 2); if (skb) { - skb->dev = dev; skb_reserve(skb, 2); skb_put(skb, len); @@ -432,7 +418,7 @@ static inline void sgiseeq_tx(struct net_device *dev, struct sgiseeq_private *sp } } -static irqreturn_t sgiseeq_interrupt(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t sgiseeq_interrupt(int irq, void *dev_id) { struct net_device *dev = (struct net_device *) dev_id; struct sgiseeq_private *sp = netdev_priv(dev); @@ -546,7 +532,7 @@ static int sgiseeq_start_xmit(struct sk_buff *skb, struct net_device *dev) * entry and the HPC got to the end of the chain before we * added this new entry and restarted it. */ - memcpy((char *)(long)td->buf_vaddr, skb->data, skblen); + skb_copy_from_linear_data(skb, (char *)(long)td->buf_vaddr, skblen); if (len != skblen) memset((char *)(long)td->buf_vaddr + skb->len, 0, len-skblen); td->tdma.cntinfo = (len & HPCDMA_BCNT) | @@ -636,9 +622,12 @@ static inline void setup_rx_ring(struct sgiseeq_rx_desc *buf, int nbufs) #define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf)) -static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq) +static int __init sgiseeq_probe(struct platform_device *pdev) { + struct sgiseeq_platform_data *pd = pdev->dev.platform_data; + struct hpc3_regs *hpcregs = pd->hpc; struct sgiseeq_init_block *sr; + unsigned int irq = pd->irq; struct sgiseeq_private *sp; struct net_device *dev; int err, i; @@ -649,6 +638,8 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq) err = -ENOMEM; goto err_out; } + + platform_set_drvdata(pdev, dev); sp = netdev_priv(dev); /* Make private data page aligned */ @@ -660,13 +651,7 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq) } sp->srings = sr; -#define EADDR_NVOFS 250 - for (i = 0; i < 3; i++) { - unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i); - - dev->dev_addr[2 * i] = tmp >> 8; - dev->dev_addr[2 * i + 1] = tmp & 0xff; - } + memcpy(dev->dev_addr, pd->mac, ETH_ALEN); #ifdef DEBUG gpriv = sp; @@ -690,6 +675,11 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq) setup_rx_ring(sp->rx_desc, SEEQ_RX_BUFFERS); setup_tx_ring(sp->tx_desc, SEEQ_TX_BUFFERS); + /* Setup PIO and DMA transfer timing */ + sp->hregs->pconfig = 0x161; + sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP | + HPC3_EDCFG_FRXDC | HPC3_EDCFG_PTO | 0x026; + /* Setup PIO and DMA transfer timing */ sp->hregs->pconfig = 0x161; sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP | @@ -725,9 +715,6 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq) for (i = 0; i < 6; i++) printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':'); - sp->next_module = root_sgiseeq_dev; - root_sgiseeq_dev = dev; - return 0; err_out_free_page: @@ -739,28 +726,42 @@ err_out: return err; } -static int __init sgiseeq_probe(void) +static void __exit sgiseeq_remove(struct platform_device *pdev) { - /* On board adapter on 1st HPC is always present */ - return sgiseeq_init(hpc3c0, SGI_ENET_IRQ); + struct net_device *dev = platform_get_drvdata(pdev); + struct sgiseeq_private *sp = netdev_priv(dev); + + unregister_netdev(dev); + free_page((unsigned long) sp->srings); + free_netdev(dev); + platform_set_drvdata(pdev, NULL); } -static void __exit sgiseeq_exit(void) -{ - struct net_device *next, *dev; - struct sgiseeq_private *sp; +static struct platform_driver sgiseeq_driver = { + .probe = sgiseeq_probe, + .remove = __devexit_p(sgiseeq_remove), + .driver = { + .name = "sgiseeq" + } +}; - for (dev = root_sgiseeq_dev; dev; dev = next) { - sp = (struct sgiseeq_private *) netdev_priv(dev); - next = sp->next_module; - unregister_netdev(dev); - free_page((unsigned long) sp->srings); - free_netdev(dev); +static int __init sgiseeq_module_init(void) +{ + if (platform_driver_register(&sgiseeq_driver)) { + printk(KERN_ERR "Driver registration failed\n"); + return -ENODEV; } + + return 0; +} + +static void __exit sgiseeq_module_exit(void) +{ + platform_driver_unregister(&sgiseeq_driver); } -module_init(sgiseeq_probe); -module_exit(sgiseeq_exit); +module_init(sgiseeq_module_init); +module_exit(sgiseeq_module_exit); MODULE_DESCRIPTION("SGI Seeq 8003 driver"); MODULE_AUTHOR("Linux/MIPS Mailing List ");