X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fnet%2Fhamradio%2Fhdlcdrv.c;h=dacc7687b97f8b2bfe3290ede1cd6137c5ed08d9;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=86deb52100be1c383f515d67dbc9a3a30cdc5aaf;hpb=9bf4aaab3e101692164d49b7ca357651eb691cb6;p=linux-2.6.git diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c index 86deb5210..dacc7687b 100644 --- a/drivers/net/hamradio/hdlcdrv.c +++ b/drivers/net/hamradio/hdlcdrv.c @@ -42,7 +42,6 @@ /*****************************************************************************/ -#include #include #include #include @@ -51,21 +50,15 @@ #include #include #include -#include -#include +#include #include #include -#include #include #include -/* prototypes for ax25_encapsulate and ax25_rebuild_header */ #include +#include -/* make genksyms happy */ -#include -#include -#include #include /* --------------------------------------------------------------------- */ @@ -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);