Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / net / hamradio / hdlcdrv.c
index 86deb52..dacc768 100644 (file)
@@ -42,7 +42,6 @@
 
 /*****************************************************************************/
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/net.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/init.h>
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
+#include <linux/bitops.h>
 
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
-#include <linux/etherdevice.h>
 #include <linux/skbuff.h>
 #include <linux/hdlcdrv.h>
-/* prototypes for ax25_encapsulate and ax25_rebuild_header */
 #include <net/ax25.h> 
+#include <asm/uaccess.h>
 
-/* make genksyms happy */
-#include <linux/ip.h>
-#include <linux/udp.h>
-#include <linux/tcp.h>
 #include <linux/crc-ccitt.h>
 
 /* --------------------------------------------------------------------- */
@@ -174,12 +167,10 @@ static void hdlc_rx_flag(struct net_device *dev, struct hdlcdrv_state *s)
                s->stats.rx_dropped++;
                return;
        }
-       skb->dev = dev;
        cp = skb_put(skb, pkt_len);
        *cp++ = 0; /* KISS kludge */
        memcpy(cp, s->hdlcrx.buffer, pkt_len - 1);
-       skb->protocol = htons(ETH_P_AX25);
-       skb->mac.raw = skb->data;
+       skb->protocol = ax25_type_trans(skb, dev);
        netif_rx(skb);
        dev->last_rx = jiffies;
        s->stats.rx_packets++;
@@ -427,27 +418,10 @@ void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
  * ===================== network driver interface =========================
  */
 
-static inline int hdlcdrv_paranoia_check(struct net_device *dev,
-                                       const char *routine)
-{
-       if (!dev || !dev->priv || 
-           ((struct hdlcdrv_state *)dev->priv)->magic != HDLCDRV_MAGIC) {
-               printk(KERN_ERR "hdlcdrv: bad magic number for hdlcdrv_state "
-                      "struct in routine %s\n", routine);
-               return 1;
-       }
-       return 0;
-}
-
-/* --------------------------------------------------------------------- */
-
 static int hdlcdrv_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
-       struct hdlcdrv_state *sm;
+       struct hdlcdrv_state *sm = netdev_priv(dev);
 
-       if (hdlcdrv_paranoia_check(dev, "hdlcdrv_send_packet"))
-               return 0;
-       sm = (struct hdlcdrv_state *)dev->priv;
        if (skb->data[0] != 0) {
                do_kiss_params(sm, skb->data, skb->len);
                dev_kfree_skb(skb);
@@ -475,11 +449,8 @@ 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;
+       struct hdlcdrv_state *sm = netdev_priv(dev);
 
-       if (hdlcdrv_paranoia_check(dev, "hdlcdrv_get_stats"))
-               return NULL;
-       sm = (struct hdlcdrv_state *)dev->priv;
        /* 
         * Get the current statistics.  This may be called with the
         * card open or closed. 
@@ -499,13 +470,9 @@ static struct net_device_stats *hdlcdrv_get_stats(struct net_device *dev)
 
 static int hdlcdrv_open(struct net_device *dev)
 {
-       struct hdlcdrv_state *s;
+       struct hdlcdrv_state *s = netdev_priv(dev);
        int i;
 
-       if (hdlcdrv_paranoia_check(dev, "hdlcdrv_open"))
-               return -EINVAL;
-       s = (struct hdlcdrv_state *)dev->priv;
-
        if (!s->ops || !s->ops->open)
                return -ENODEV;
 
@@ -540,13 +507,9 @@ static int hdlcdrv_open(struct net_device *dev)
 
 static int hdlcdrv_close(struct net_device *dev)
 {
-       struct hdlcdrv_state *s;
+       struct hdlcdrv_state *s = netdev_priv(dev);
        int i = 0;
 
-       if (hdlcdrv_paranoia_check(dev, "hdlcdrv_close"))
-               return -EINVAL;
-       s = (struct hdlcdrv_state *)dev->priv;
-
        netif_stop_queue(dev);
 
        if (s->ops && s->ops->close)
@@ -562,12 +525,8 @@ static int hdlcdrv_close(struct net_device *dev)
 
 static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-       struct hdlcdrv_state *s;
+       struct hdlcdrv_state *s = netdev_priv(dev);
        struct hdlcdrv_ioctl bi;
-               
-       if (hdlcdrv_paranoia_check(dev, "hdlcdrv_ioctl"))
-               return -EINVAL;
-       s = (struct hdlcdrv_state *)dev->priv;
 
        if (cmd != SIOCDEVPRIVATE) {
                if (s->ops && s->ops->ioctl)
@@ -698,7 +657,7 @@ static void hdlcdrv_setup(struct net_device *dev)
        static const struct hdlcdrv_channel_params dflt_ch_params = { 
                20, 2, 10, 40, 0 
        };
-       struct hdlcdrv_state *s = dev->priv;
+       struct hdlcdrv_state *s = netdev_priv(dev);
 
        /*
         * initialize the hdlcdrv_state struct
@@ -742,13 +701,8 @@ static void hdlcdrv_setup(struct net_device *dev)
 
        s->skb = NULL;
        
-#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
-       dev->hard_header = ax25_encapsulate;
+       dev->hard_header = ax25_hard_header;
        dev->rebuild_header = ax25_rebuild_header;
-#else /* CONFIG_AX25 || CONFIG_AX25_MODULE */
-       dev->hard_header = NULL;
-       dev->rebuild_header = NULL;
-#endif /* CONFIG_AX25 || CONFIG_AX25_MODULE */
        dev->set_mac_address = hdlcdrv_set_mac_address;
        
        dev->type = ARPHRD_AX25;           /* AF_AX25 device */
@@ -782,7 +736,7 @@ struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
        /*
         * initialize part of the hdlcdrv_state struct
         */
-       s = dev->priv;
+       s = netdev_priv(dev);
        s->magic = HDLCDRV_MAGIC;
        s->ops = ops;
        dev->base_addr = baseaddr;
@@ -803,7 +757,7 @@ struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
 
 void hdlcdrv_unregister(struct net_device *dev) 
 {
-       struct hdlcdrv_state *s = dev->priv;
+       struct hdlcdrv_state *s = netdev_priv(dev);
 
        BUG_ON(s->magic != HDLCDRV_MAGIC);