MAINTAINERS: remove Adam Fritzler, remove his email address in other sources
[linux-2.6.git] / drivers / net / tokenring / tms380tr.c
index 5e0b0ce..d07c452 100644 (file)
@@ -30,7 +30,7 @@
  *  Maintainer(s):
  *    JS       Jay Schulist            jschlst@samba.org
  *    CG       Christoph Goos          cgoos@syskonnect.de
- *    AF       Adam Fritzler           mid@auk.cx
+ *    AF       Adam Fritzler
  *    MLP       Mike Phillips           phillim@amtrak.com
  *    JF       Jochen Friedrich        jochen@scram.de
  *     
@@ -62,6 +62,7 @@
  *                             normal operation.
  *     30-Dec-02       JF      Removed incorrect __init from 
  *                             tms380tr_init_card.
+ *     22-Jul-05       JF      Converted to dma-mapping.
  *                             
  *  To do:
  *    1. Multi/Broadcast packet handling (this may have fixed itself)
@@ -89,7 +90,7 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A
 #include <linux/time.h>
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -114,8 +115,6 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A
 #endif
 static unsigned int tms380tr_debug = TMS380TR_DEBUG;
 
-static struct device tms_device;
-
 /* Index to functions, as function prototypes.
  * Alphabetical by function name.
  */
@@ -434,7 +433,7 @@ static void tms380tr_init_net_local(struct net_device *dev)
                        skb_put(tp->Rpl[i].Skb, tp->MaxPacketSize);
 
                        /* data unreachable for DMA ? then use local buffer */
-                       dmabuf = pci_map_single(tp->pdev, tp->Rpl[i].Skb->data, tp->MaxPacketSize, PCI_DMA_FROMDEVICE);
+                       dmabuf = dma_map_single(tp->pdev, tp->Rpl[i].Skb->data, tp->MaxPacketSize, DMA_FROM_DEVICE);
                        if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit))
                        {
                                tp->Rpl[i].SkbStat = SKB_DATA_COPY;
@@ -638,14 +637,14 @@ static int tms380tr_hardware_send_packet(struct sk_buff *skb, struct net_device
        /* Is buffer reachable for Busmaster-DMA? */
 
        length  = skb->len;
-       dmabuf = pci_map_single(tp->pdev, skb->data, length, PCI_DMA_TODEVICE);
+       dmabuf = dma_map_single(tp->pdev, skb->data, length, DMA_TO_DEVICE);
        if(tp->dmalimit && (dmabuf + length > tp->dmalimit)) {
                /* Copy frame to local buffer */
-               pci_unmap_single(tp->pdev, dmabuf, length, PCI_DMA_TODEVICE);
+               dma_unmap_single(tp->pdev, dmabuf, length, DMA_TO_DEVICE);
                dmabuf  = 0;
                i       = tp->TplFree->TPLIndex;
                buf     = tp->LocalTxBuffers[i];
-               memcpy(buf, skb->data, length);
+               skb_copy_from_linear_data(skb, buf, length);
                newbuf  = ((char *)buf - (char *)tp) + tp->dmabuffer;
        }
        else {
@@ -745,18 +744,13 @@ static void tms380tr_timer_chk(unsigned long data)
 /*
  * The typical workload of the driver: Handle the network interface interrupts.
  */
-irqreturn_t tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t tms380tr_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = dev_id;
        struct net_local *tp;
        unsigned short irq_type;
        int handled = 0;
 
-       if(dev == NULL) {
-               printk(KERN_INFO "%s: irq %d for unknown device.\n", dev->name, irq);
-               return IRQ_NONE;
-       }
-
        tp = netdev_priv(dev);
 
        irq_type = SIFREADW(SIFSTS);
@@ -1244,8 +1238,7 @@ void tms380tr_wait(unsigned long time)
        
        tmp = jiffies + time/(1000000/HZ);
        do {
-               current->state          = TASK_INTERRUPTIBLE;
-               tmp = schedule_timeout(tmp);
+               tmp = schedule_timeout_interruptible(tmp);
        } while(time_after(tmp, jiffies));
 #else
        udelay(time);
@@ -1284,9 +1277,7 @@ static int tms380tr_reset_adapter(struct net_device *dev)
        unsigned short count, c, count2;
        const struct firmware *fw_entry = NULL;
 
-       strncpy(tms_device.bus_id,dev->name, BUS_ID_SIZE);
-
-       if (request_firmware(&fw_entry, "tms380tr.bin", &tms_device) != 0) {
+       if (request_firmware(&fw_entry, "tms380tr.bin", tp->pdev) != 0) {
                printk(KERN_ALERT "%s: firmware %s is missing, cannot start.\n",
                        dev->name, "tms380tr.bin");
                return (-1);
@@ -2021,7 +2012,7 @@ static void tms380tr_cancel_tx_queue(struct net_local* tp)
 
                printk(KERN_INFO "Cancel tx (%08lXh).\n", (unsigned long)tpl);
                if (tpl->DMABuff)
-                       pci_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, PCI_DMA_TODEVICE);
+                       dma_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, DMA_TO_DEVICE);
                dev_kfree_skb_any(tpl->Skb);
        }
 
@@ -2090,7 +2081,7 @@ static void tms380tr_tx_status_irq(struct net_device *dev)
 
                tp->MacStat.tx_packets++;
                if (tpl->DMABuff)
-                       pci_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, PCI_DMA_TODEVICE);
+                       dma_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, DMA_TO_DEVICE);
                dev_kfree_skb_irq(tpl->Skb);
                tpl->BusyFlag = 0;      /* "free" TPL */
        }
@@ -2133,7 +2124,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
                /* Get the frame size (Byte swap for Intel).
                 * Do this early (see workaround comment below)
                 */
-               Length = be16_to_cpu((unsigned short)rpl->FrameSize);
+               Length = be16_to_cpu(rpl->FrameSize);
 
                /* Check if the Frame_Start, Frame_End and
                 * Frame_Complete bits are set.
@@ -2149,7 +2140,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
                         * Length2 is there because there have also been
                         * cases where the FrameSize was partially written
                         */
-                       Length2 = be16_to_cpu((unsigned short)rpl->FrameSize);
+                       Length2 = be16_to_cpu(rpl->FrameSize);
 
                        if(Length == 0 || Length != Length2)
                        {
@@ -2177,7 +2168,6 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
                                }
                                else
                                {
-                                       skb->dev        = dev;
                                        skb_put(skb, tp->MaxPacketSize);
                                        rpl->SkbStat    = SKB_DATA_COPY;
                                        ReceiveDataPtr  = rpl->MData;
@@ -2188,7 +2178,8 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
                                || rpl->SkbStat == SKB_DMA_DIRECT))
                        {
                                if(rpl->SkbStat == SKB_DATA_COPY)
-                                       memcpy(skb->data, ReceiveDataPtr, Length);
+                                       skb_copy_to_linear_data(skb, ReceiveDataPtr,
+                                                      Length);
 
                                /* Deliver frame to system */
                                rpl->Skb = NULL;
@@ -2209,7 +2200,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
                                tp->MacStat.rx_errors++;
                }
                if (rpl->DMABuff)
-                       pci_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, PCI_DMA_TODEVICE);
+                       dma_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, DMA_TO_DEVICE);
                rpl->DMABuff = 0;
 
                /* Allocate new skb for rpl */
@@ -2227,7 +2218,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
                        skb_put(rpl->Skb, tp->MaxPacketSize);
 
                        /* Data unreachable for DMA ? then use local buffer */
-                       dmabuf = pci_map_single(tp->pdev, rpl->Skb->data, tp->MaxPacketSize, PCI_DMA_FROMDEVICE);
+                       dmabuf = dma_map_single(tp->pdev, rpl->Skb->data, tp->MaxPacketSize, DMA_FROM_DEVICE);
                        if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit))
                        {
                                rpl->SkbStat = SKB_DATA_COPY;
@@ -2332,23 +2323,26 @@ void tmsdev_term(struct net_device *dev)
        struct net_local *tp;
 
        tp = netdev_priv(dev);
-       pci_unmap_single(tp->pdev, tp->dmabuffer, sizeof(struct net_local),
-               PCI_DMA_BIDIRECTIONAL);
+       dma_unmap_single(tp->pdev, tp->dmabuffer, sizeof(struct net_local),
+               DMA_BIDIRECTIONAL);
 }
 
-int tmsdev_init(struct net_device *dev, unsigned long dmalimit, 
-               struct pci_dev *pdev)
+int tmsdev_init(struct net_device *dev, struct device *pdev)
 {
        struct net_local *tms_local;
 
        memset(dev->priv, 0, sizeof(struct net_local));
        tms_local = netdev_priv(dev);
        init_waitqueue_head(&tms_local->wait_for_tok_int);
-       tms_local->dmalimit = dmalimit;
+       if (pdev->dma_mask)
+               tms_local->dmalimit = *pdev->dma_mask;
+       else
+               return -ENOMEM;
        tms_local->pdev = pdev;
-       tms_local->dmabuffer = pci_map_single(pdev, (void *)tms_local,
-           sizeof(struct net_local), PCI_DMA_BIDIRECTIONAL);
-       if (tms_local->dmabuffer + sizeof(struct net_local) > dmalimit)
+       tms_local->dmabuffer = dma_map_single(pdev, (void *)tms_local,
+           sizeof(struct net_local), DMA_BIDIRECTIONAL);
+       if (tms_local->dmabuffer + sizeof(struct net_local) > 
+                       tms_local->dmalimit)
        {
                printk(KERN_INFO "%s: Memory not accessible for DMA\n",
                        dev->name);
@@ -2370,8 +2364,6 @@ int tmsdev_init(struct net_device *dev, unsigned long dmalimit,
        return 0;
 }
 
-#ifdef MODULE
-
 EXPORT_SYMBOL(tms380tr_open);
 EXPORT_SYMBOL(tms380tr_close);
 EXPORT_SYMBOL(tms380tr_interrupt);
@@ -2379,6 +2371,8 @@ EXPORT_SYMBOL(tmsdev_init);
 EXPORT_SYMBOL(tmsdev_term);
 EXPORT_SYMBOL(tms380tr_wait);
 
+#ifdef MODULE
+
 static struct module *TMS380_module = NULL;
 
 int init_module(void)