include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / net / hamradio / hdlcdrv.c
index f5a17ad..b8bdf9d 100644 (file)
 
 /*****************************************************************************/
 
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/net.h>
 #include <linux/in.h>
 #include <linux/if.h>
-#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/bitops.h>
@@ -88,6 +88,7 @@
 static inline void append_crc_ccitt(unsigned char *buffer, int len)
 {
        unsigned int crc = crc_ccitt(0xffff, buffer, len) ^ 0xffff;
+       buffer += len;
        *buffer++ = crc;
        *buffer++ = crc >> 8;
 }
@@ -153,7 +154,7 @@ static void hdlc_rx_flag(struct net_device *dev, struct hdlcdrv_state *s)
        pkt_len = s->hdlcrx.len - 2 + 1; /* KISS kludge */
        if (!(skb = dev_alloc_skb(pkt_len))) {
                printk("%s: memory squeeze, dropping packet\n", dev->name);
-               s->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                return;
        }
        cp = skb_put(skb, pkt_len);
@@ -161,8 +162,7 @@ static void hdlc_rx_flag(struct net_device *dev, struct hdlcdrv_state *s)
        memcpy(cp, s->hdlcrx.buffer, pkt_len - 1);
        skb->protocol = ax25_type_trans(skb, dev);
        netif_rx(skb);
-       dev->last_rx = jiffies;
-       s->stats.rx_packets++;
+       dev->stats.rx_packets++;
 }
 
 void hdlcdrv_receiver(struct net_device *dev, struct hdlcdrv_state *s)
@@ -317,14 +317,16 @@ void hdlcdrv_transmitter(struct net_device *dev, struct hdlcdrv_state *s)
                                dev_kfree_skb_irq(skb);
                                break;
                        }
-                       memcpy(s->hdlctx.buffer, skb->data+1, pkt_len);
+                       skb_copy_from_linear_data_offset(skb, 1,
+                                                        s->hdlctx.buffer,
+                                                        pkt_len);
                        dev_kfree_skb_irq(skb);
                        s->hdlctx.bp = s->hdlctx.buffer;
                        append_crc_ccitt(s->hdlctx.buffer, pkt_len);
                        s->hdlctx.len = pkt_len+2; /* the appended CRC */
                        s->hdlctx.tx_state = 2;
                        s->hdlctx.bitstream = 0;
-                       s->stats.tx_packets++;
+                       dev->stats.tx_packets++;
                        break;
                case 2:
                        if (!s->hdlctx.len) {
@@ -397,20 +399,21 @@ void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
  * ===================== network driver interface =========================
  */
 
-static int hdlcdrv_send_packet(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t hdlcdrv_send_packet(struct sk_buff *skb,
+                                      struct net_device *dev)
 {
        struct hdlcdrv_state *sm = netdev_priv(dev);
 
        if (skb->data[0] != 0) {
                do_kiss_params(sm, skb->data, skb->len);
                dev_kfree_skb(skb);
-               return 0;
+               return NETDEV_TX_OK;
        }
        if (sm->skb)
-               return -1;
+               return NETDEV_TX_LOCKED;
        netif_stop_queue(dev);
        sm->skb = skb;
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /* --------------------------------------------------------------------- */
@@ -425,19 +428,6 @@ static int hdlcdrv_set_mac_address(struct net_device *dev, void *addr)
 }
 
 /* --------------------------------------------------------------------- */
-
-static struct net_device_stats *hdlcdrv_get_stats(struct net_device *dev)
-{
-       struct hdlcdrv_state *sm = netdev_priv(dev);
-
-       /* 
-        * Get the current statistics.  This may be called with the
-        * card open or closed. 
-        */
-       return &sm->stats;
-}
-
-/* --------------------------------------------------------------------- */
 /*
  * Open/initialize the board. This is called (in the current kernel)
  * sometime after booting when the 'ifconfig' program is run.
@@ -566,10 +556,10 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                bi.data.cs.ptt = hdlcdrv_ptt(s);
                bi.data.cs.dcd = s->hdlcrx.dcd;
                bi.data.cs.ptt_keyed = s->ptt_keyed;
-               bi.data.cs.tx_packets = s->stats.tx_packets;
-               bi.data.cs.tx_errors = s->stats.tx_errors;
-               bi.data.cs.rx_packets = s->stats.rx_packets;
-               bi.data.cs.rx_errors = s->stats.rx_errors;
+               bi.data.cs.tx_packets = dev->stats.tx_packets;
+               bi.data.cs.tx_errors = dev->stats.tx_errors;
+               bi.data.cs.rx_packets = dev->stats.rx_packets;
+               bi.data.cs.rx_errors = dev->stats.rx_errors;
                break;          
 
        case HDLCDRVCTL_OLDGETSTAT:
@@ -628,6 +618,14 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 
 /* --------------------------------------------------------------------- */
 
+static const struct net_device_ops hdlcdrv_netdev = {
+       .ndo_open       = hdlcdrv_open,
+       .ndo_stop       = hdlcdrv_close,
+       .ndo_start_xmit = hdlcdrv_send_packet,
+       .ndo_do_ioctl   = hdlcdrv_ioctl,
+       .ndo_set_mac_address = hdlcdrv_set_mac_address,
+};
+
 /*
  * Initialize fields in hdlcdrv
  */
@@ -667,22 +665,13 @@ static void hdlcdrv_setup(struct net_device *dev)
        s->bitbuf_hdlc.shreg = 0x80;
 #endif /* HDLCDRV_DEBUG */
 
-       /*
-        * initialize the device struct
-        */
-       dev->open = hdlcdrv_open;
-       dev->stop = hdlcdrv_close;
-       dev->do_ioctl = hdlcdrv_ioctl;
-       dev->hard_start_xmit = hdlcdrv_send_packet;
-       dev->get_stats = hdlcdrv_get_stats;
 
        /* Fill in the fields of the device structure */
 
        s->skb = NULL;
        
-       dev->hard_header = ax25_hard_header;
-       dev->rebuild_header = ax25_rebuild_header;
-       dev->set_mac_address = hdlcdrv_set_mac_address;
+       dev->netdev_ops = &hdlcdrv_netdev;
+       dev->header_ops = &ax25_header_ops;
        
        dev->type = ARPHRD_AX25;           /* AF_AX25 device */
        dev->hard_header_len = AX25_MAX_HEADER_LEN + AX25_BPQ_HEADER_LEN;