]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wan/z85230.c
net: Rationalise email address: Network Specific Parts
[linux-2.6-omap-h63xx.git] / drivers / net / wan / z85230.c
index 8b4540bfc1b0b3b7949b86ae5cd6de58ab043b2f..ccd9cd35ecbe9e7f82ca370739415add9e4026b3 100644 (file)
@@ -18,7 +18,8 @@
  *     DMA now uses get_free_page as kmalloc buffers may span a 64K 
  *     boundary.
  *
- *     Modified for SMP safety and SMP locking by Alan Cox <alan@redhat.com>
+ *     Modified for SMP safety and SMP locking by Alan Cox
+ *                                     <alan@lxorguk.ukuu.org.uk>
  *
  *     Performance
  *
@@ -43,6 +44,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
 #include <linux/delay.h>
+#include <linux/hdlc.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <asm/dma.h>
@@ -51,7 +53,6 @@
 #define RT_UNLOCK
 #include <linux/spinlock.h>
 
-#include <net/syncppp.h>
 #include "z85230.h"
 
 
@@ -440,51 +441,46 @@ static void z8530_tx(struct z8530_channel *c)
  *     A status event occurred in PIO synchronous mode. There are several
  *     reasons the chip will bother us here. A transmit underrun means we
  *     failed to feed the chip fast enough and just broke a packet. A DCD
- *     change is a line up or down. We communicate that back to the protocol
- *     layer for synchronous PPP to renegotiate.
+ *     change is a line up or down.
  */
 
 static void z8530_status(struct z8530_channel *chan)
 {
        u8 status, altered;
 
-       status=read_zsreg(chan, R0);
-       altered=chan->status^status;
-       
-       chan->status=status;
-       
-       if(status&TxEOM)
-       {
+       status = read_zsreg(chan, R0);
+       altered = chan->status ^ status;
+
+       chan->status = status;
+
+       if (status & TxEOM) {
 /*             printk("%s: Tx underrun.\n", chan->dev->name); */
-               chan->stats.tx_fifo_errors++;
+               chan->netdevice->stats.tx_fifo_errors++;
                write_zsctrl(chan, ERR_RES);
                z8530_tx_done(chan);
        }
-               
-       if(altered&chan->dcdcheck)
+
+       if (altered & chan->dcdcheck)
        {
-               if(status&chan->dcdcheck)
-               {
+               if (status & chan->dcdcheck) {
                        printk(KERN_INFO "%s: DCD raised\n", chan->dev->name);
-                       write_zsreg(chan, R3, chan->regs[3]|RxENABLE);
-                       if(chan->netdevice &&
-                           ((chan->netdevice->type == ARPHRD_HDLC) ||
-                           (chan->netdevice->type == ARPHRD_PPP)))
-                               sppp_reopen(chan->netdevice);
-               }
-               else
-               {
+                       write_zsreg(chan, R3, chan->regs[3] | RxENABLE);
+                       if (chan->netdevice)
+                               netif_carrier_on(chan->netdevice);
+               } else {
                        printk(KERN_INFO "%s: DCD lost\n", chan->dev->name);
-                       write_zsreg(chan, R3, chan->regs[3]&~RxENABLE);
+                       write_zsreg(chan, R3, chan->regs[3] & ~RxENABLE);
                        z8530_flush_fifo(chan);
+                       if (chan->netdevice)
+                               netif_carrier_off(chan->netdevice);
                }
-               
-       }       
+
+       }
        write_zsctrl(chan, RES_EXT_INT);
        write_zsctrl(chan, RES_H_IUS);
 }
 
-struct z8530_irqhandler z8530_sync=
+struct z8530_irqhandler z8530_sync =
 {
        z8530_rx,
        z8530_tx,
@@ -556,8 +552,7 @@ static void z8530_dma_tx(struct z8530_channel *chan)
  *     
  *     A status event occurred on the Z8530. We receive these for two reasons
  *     when in DMA mode. Firstly if we finished a packet transfer we get one
- *     and kick the next packet out. Secondly we may see a DCD change and
- *     have to poke the protocol layer.
+ *     and kick the next packet out. Secondly we may see a DCD change.
  *
  */
  
@@ -586,24 +581,21 @@ static void z8530_dma_status(struct z8530_channel *chan)
                }
        }
 
-       if(altered&chan->dcdcheck)
+       if (altered & chan->dcdcheck)
        {
-               if(status&chan->dcdcheck)
-               {
+               if (status & chan->dcdcheck) {
                        printk(KERN_INFO "%s: DCD raised\n", chan->dev->name);
-                       write_zsreg(chan, R3, chan->regs[3]|RxENABLE);
-                       if(chan->netdevice &&
-                           ((chan->netdevice->type == ARPHRD_HDLC) ||
-                           (chan->netdevice->type == ARPHRD_PPP)))
-                               sppp_reopen(chan->netdevice);
-               }
-               else
-               {
+                       write_zsreg(chan, R3, chan->regs[3] | RxENABLE);
+                       if (chan->netdevice)
+                               netif_carrier_on(chan->netdevice);
+               } else {
                        printk(KERN_INFO "%s:DCD lost\n", chan->dev->name);
-                       write_zsreg(chan, R3, chan->regs[3]&~RxENABLE);
+                       write_zsreg(chan, R3, chan->regs[3] & ~RxENABLE);
                        z8530_flush_fifo(chan);
+                       if (chan->netdevice)
+                               netif_carrier_off(chan->netdevice);
                }
-       }       
+       }
 
        write_zsctrl(chan, RES_EXT_INT);
        write_zsctrl(chan, RES_H_IUS);
@@ -1459,10 +1451,10 @@ static void z8530_tx_begin(struct z8530_channel *c)
                        /*
                         *      Check if we crapped out.
                         */
-                       if(get_dma_residue(c->txdma))
+                       if (get_dma_residue(c->txdma))
                        {
-                               c->stats.tx_dropped++;
-                               c->stats.tx_fifo_errors++;
+                               c->netdevice->stats.tx_dropped++;
+                               c->netdevice->stats.tx_fifo_errors++;
                        }
                        release_dma_lock(flags);
                }
@@ -1534,21 +1526,21 @@ static void z8530_tx_begin(struct z8530_channel *c)
  *     packet. This code is fairly timing sensitive.
  *
  *     Called with the register lock held.
- */ 
+ */
+
 static void z8530_tx_done(struct z8530_channel *c)
 {
        struct sk_buff *skb;
 
        /* Actually this can happen.*/
-       if(c->tx_skb==NULL)
+       if (c->tx_skb == NULL)
                return;
 
-       skb=c->tx_skb;
-       c->tx_skb=NULL;
+       skb = c->tx_skb;
+       c->tx_skb = NULL;
        z8530_tx_begin(c);
-       c->stats.tx_packets++;
-       c->stats.tx_bytes+=skb->len;
+       c->netdevice->stats.tx_packets++;
+       c->netdevice->stats.tx_bytes += skb->len;
        dev_kfree_skb_irq(skb);
 }
 
@@ -1558,7 +1550,7 @@ static void z8530_tx_done(struct z8530_channel *c)
  *     @skb: The buffer
  *
  *     We point the receive handler at this function when idle. Instead
- *     of syncppp processing the frames we get to throw them away.
+ *     of processing the frames we get to throw them away.
  */
  
 void z8530_null_rx(struct z8530_channel *c, struct sk_buff *skb)
@@ -1635,10 +1627,11 @@ static void z8530_rx_done(struct z8530_channel *c)
                else
                        /* Can't occur as we dont reenable the DMA irq until
                           after the flip is done */
-                       printk(KERN_WARNING "%s: DMA flip overrun!\n", c->netdevice->name);
-                       
+                       printk(KERN_WARNING "%s: DMA flip overrun!\n",
+                              c->netdevice->name);
+
                release_dma_lock(flags);
-               
+
                /*
                 *      Shove the old buffer into an sk_buff. We can't DMA
                 *      directly into one on a PC - it might be above the 16Mb
@@ -1646,27 +1639,23 @@ static void z8530_rx_done(struct z8530_channel *c)
                 *      can avoid the copy. Optimisation 2 - make the memcpy
                 *      a copychecksum.
                 */
-                
-               skb=dev_alloc_skb(ct);
-               if(skb==NULL)
-               {
-                       c->stats.rx_dropped++;
-                       printk(KERN_WARNING "%s: Memory squeeze.\n", c->netdevice->name);
-               }
-               else
-               {
+
+               skb = dev_alloc_skb(ct);
+               if (skb == NULL) {
+                       c->netdevice->stats.rx_dropped++;
+                       printk(KERN_WARNING "%s: Memory squeeze.\n",
+                              c->netdevice->name);
+               } else {
                        skb_put(skb, ct);
-                       memcpy(skb->data, rxb, ct);
-                       c->stats.rx_packets++;
-                       c->stats.rx_bytes+=ct;
+                       skb_copy_to_linear_data(skb, rxb, ct);
+                       c->netdevice->stats.rx_packets++;
+                       c->netdevice->stats.rx_bytes += ct;
                }
-               c->dma_ready=1;
-       }
-       else
-       {
-               RT_LOCK;        
-               skb=c->skb;
-               
+               c->dma_ready = 1;
+       } else {
+               RT_LOCK;
+               skb = c->skb;
+
                /*
                 *      The game we play for non DMA is similar. We want to
                 *      get the controller set up for the next packet as fast
@@ -1677,48 +1666,39 @@ static void z8530_rx_done(struct z8530_channel *c)
                 *      if you build a system where the sync irq isnt blocked
                 *      by the kernel IRQ disable then you need only block the
                 *      sync IRQ for the RT_LOCK area.
-                *      
+                *
                 */
                ct=c->count;
-               
+
                c->skb = c->skb2;
                c->count = 0;
                c->max = c->mtu;
-               if(c->skb)
-               {
+               if (c->skb) {
                        c->dptr = c->skb->data;
                        c->max = c->mtu;
-               }
-               else
-               {
-                       c->count= 0;
+               } else {
+                       c->count = 0;
                        c->max = 0;
                }
                RT_UNLOCK;
 
                c->skb2 = dev_alloc_skb(c->mtu);
-               if(c->skb2==NULL)
+               if (c->skb2 == NULL)
                        printk(KERN_WARNING "%s: memory squeeze.\n",
-                               c->netdevice->name);
+                              c->netdevice->name);
                else
-               {
-                       skb_put(c->skb2,c->mtu);
-               }
-               c->stats.rx_packets++;
-               c->stats.rx_bytes+=ct;
-               
+                       skb_put(c->skb2, c->mtu);
+               c->netdevice->stats.rx_packets++;
+               c->netdevice->stats.rx_bytes += ct;
        }
        /*
         *      If we received a frame we must now process it.
         */
-       if(skb)
-       {
+       if (skb) {
                skb_trim(skb, ct);
-               c->rx_function(c,skb);
-       }
-       else
-       {
-               c->stats.rx_dropped++;
+               c->rx_function(c, skb);
+       } else {
+               c->netdevice->stats.rx_dropped++;
                printk(KERN_ERR "%s: Lost a frame\n", c->netdevice->name);
        }
 }
@@ -1730,7 +1710,7 @@ static void z8530_rx_done(struct z8530_channel *c)
  *     Returns true if the buffer cross a DMA boundary on a PC. The poor
  *     thing can only DMA within a 64K block not across the edges of it.
  */
+
 static inline int spans_boundary(struct sk_buff *skb)
 {
        unsigned long a=(unsigned long)skb->data;
@@ -1782,7 +1762,7 @@ int z8530_queue_xmit(struct z8530_channel *c, struct sk_buff *skb)
                 */
                c->tx_next_ptr=c->tx_dma_buf[c->tx_dma_used];
                c->tx_dma_used^=1;      /* Flip temp buffer */
-               memcpy(c->tx_next_ptr, skb->data, skb->len);
+               skb_copy_from_linear_data(skb, c->tx_next_ptr, skb->len);
        }
        else
                c->tx_next_ptr=skb->data;       
@@ -1799,24 +1779,6 @@ int z8530_queue_xmit(struct z8530_channel *c, struct sk_buff *skb)
 
 EXPORT_SYMBOL(z8530_queue_xmit);
 
-/**
- *     z8530_get_stats - Get network statistics
- *     @c: The channel to use
- *
- *     Get the statistics block. We keep the statistics in software as
- *     the chip doesn't do it for us.
- *
- *     Locking is ignored here - we could lock for a copy but its
- *     not likely to be that big an issue
- */
-struct net_device_stats *z8530_get_stats(struct z8530_channel *c)
-{
-       return &c->stats;
-}
-
-EXPORT_SYMBOL(z8530_get_stats);
-
 /*
  *     Module support
  */