Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Generic HDLC - remove now unneeded hdlc_device_desc

Removes now unneeded struct hdlc_device_desc

Signed-off-by: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by

Krzysztof Halasa and committed by
Jeff Garzik
40d25142 983e2304

+31 -46
+9 -15
drivers/net/wan/hdlc.c
··· 1 1 /* 2 2 * Generic HDLC support routines for Linux 3 3 * 4 - * Copyright (C) 1999 - 2006 Krzysztof Halasa <khc@pm.waw.pl> 4 + * Copyright (C) 1999 - 2008 Krzysztof Halasa <khc@pm.waw.pl> 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it 7 7 * under the terms of version 2 of the GNU General Public License ··· 39 39 #include <net/net_namespace.h> 40 40 41 41 42 - static const char* version = "HDLC support module revision 1.21"; 42 + static const char* version = "HDLC support module revision 1.22"; 43 43 44 44 #undef DEBUG_LINK 45 45 ··· 66 66 static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev, 67 67 struct packet_type *p, struct net_device *orig_dev) 68 68 { 69 - struct hdlc_device_desc *desc = dev_to_desc(dev); 69 + struct hdlc_device *hdlc = dev_to_hdlc(dev); 70 70 71 71 if (dev->nd_net != &init_net) { 72 72 kfree_skb(skb); 73 73 return 0; 74 74 } 75 75 76 - if (desc->netif_rx) 77 - return desc->netif_rx(skb); 78 - 79 - desc->stats.rx_dropped++; /* Shouldn't happen */ 80 - dev_kfree_skb(skb); 81 - return NET_RX_DROP; 76 + BUG_ON(!hdlc->proto->netif_rx); 77 + return hdlc->proto->netif_rx(skb); 82 78 } 83 79 84 80 ··· 83 87 { 84 88 hdlc_device *hdlc = dev_to_hdlc(dev); 85 89 if (hdlc->proto->start) 86 - return hdlc->proto->start(dev); 90 + hdlc->proto->start(dev); 87 91 } 88 92 89 93 ··· 92 96 { 93 97 hdlc_device *hdlc = dev_to_hdlc(dev); 94 98 if (hdlc->proto->stop) 95 - return hdlc->proto->stop(dev); 99 + hdlc->proto->stop(dev); 96 100 } 97 101 98 102 ··· 259 263 struct net_device *alloc_hdlcdev(void *priv) 260 264 { 261 265 struct net_device *dev; 262 - dev = alloc_netdev(sizeof(struct hdlc_device_desc) + 263 - sizeof(hdlc_device), "hdlc%d", hdlc_setup); 266 + dev = alloc_netdev(sizeof(struct hdlc_device), "hdlc%d", hdlc_setup); 264 267 if (dev) 265 268 dev_to_hdlc(dev)->priv = priv; 266 269 return dev; ··· 276 281 277 282 278 283 int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, 279 - int (*rx)(struct sk_buff *skb), size_t size) 284 + size_t size) 280 285 { 281 286 detach_hdlc_protocol(dev); 282 287 ··· 292 297 return -ENOBUFS; 293 298 } 294 299 dev_to_hdlc(dev)->proto = proto; 295 - dev_to_desc(dev)->netif_rx = rx; 296 300 return 0; 297 301 } 298 302
+3 -2
drivers/net/wan/hdlc_cisco.c
··· 250 250 return NET_RX_DROP; 251 251 252 252 rx_error: 253 - dev_to_desc(dev)->stats.rx_errors++; /* Mark error */ 253 + dev_to_hdlc(dev)->stats.rx_errors++; /* Mark error */ 254 254 dev_kfree_skb_any(skb); 255 255 return NET_RX_DROP; 256 256 } ··· 314 314 .stop = cisco_stop, 315 315 .type_trans = cisco_type_trans, 316 316 .ioctl = cisco_ioctl, 317 + .netif_rx = cisco_rx, 317 318 .module = THIS_MODULE, 318 319 }; 319 320 ··· 361 360 if (result) 362 361 return result; 363 362 364 - result = attach_hdlc_protocol(dev, &proto, cisco_rx, 363 + result = attach_hdlc_protocol(dev, &proto, 365 364 sizeof(struct cisco_state)); 366 365 if (result) 367 366 return result;
+4 -3
drivers/net/wan/hdlc_fr.c
··· 956 956 957 957 958 958 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) { 959 - dev_to_desc(frad)->stats.rx_dropped++; 959 + dev_to_hdlc(frad)->stats.rx_dropped++; 960 960 return NET_RX_DROP; 961 961 } 962 962 ··· 1017 1017 } 1018 1018 1019 1019 rx_error: 1020 - dev_to_desc(frad)->stats.rx_errors++; /* Mark error */ 1020 + dev_to_hdlc(frad)->stats.rx_errors++; /* Mark error */ 1021 1021 dev_kfree_skb_any(skb); 1022 1022 return NET_RX_DROP; 1023 1023 } ··· 1217 1217 .stop = fr_stop, 1218 1218 .detach = fr_destroy, 1219 1219 .ioctl = fr_ioctl, 1220 + .netif_rx = fr_rx, 1220 1221 .module = THIS_MODULE, 1221 1222 }; 1222 1223 ··· 1276 1275 return result; 1277 1276 1278 1277 if (dev_to_hdlc(dev)->proto != &proto) { /* Different proto */ 1279 - result = attach_hdlc_protocol(dev, &proto, fr_rx, 1278 + result = attach_hdlc_protocol(dev, &proto, 1280 1279 sizeof(struct frad_state)); 1281 1280 if (result) 1282 1281 return result;
+1 -1
drivers/net/wan/hdlc_ppp.c
··· 122 122 if (result) 123 123 return result; 124 124 125 - result = attach_hdlc_protocol(dev, &proto, NULL, 125 + result = attach_hdlc_protocol(dev, &proto, 126 126 sizeof(struct ppp_state)); 127 127 if (result) 128 128 return result;
+1 -1
drivers/net/wan/hdlc_raw.c
··· 82 82 if (result) 83 83 return result; 84 84 85 - result = attach_hdlc_protocol(dev, &proto, NULL, 85 + result = attach_hdlc_protocol(dev, &proto, 86 86 sizeof(raw_hdlc_proto)); 87 87 if (result) 88 88 return result;
+1 -1
drivers/net/wan/hdlc_raw_eth.c
··· 96 96 if (result) 97 97 return result; 98 98 99 - result = attach_hdlc_protocol(dev, &proto, NULL, 99 + result = attach_hdlc_protocol(dev, &proto, 100 100 sizeof(raw_hdlc_proto)); 101 101 if (result) 102 102 return result;
+5 -5
drivers/net/wan/hdlc_x25.c
··· 164 164 165 165 static int x25_rx(struct sk_buff *skb) 166 166 { 167 - struct hdlc_device_desc *desc = dev_to_desc(skb->dev); 167 + struct hdlc_device *hdlc = dev_to_hdlc(skb->dev); 168 168 169 169 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) { 170 - desc->stats.rx_dropped++; 170 + hdlc->stats.rx_dropped++; 171 171 return NET_RX_DROP; 172 172 } 173 173 174 174 if (lapb_data_received(skb->dev, skb) == LAPB_OK) 175 175 return NET_RX_SUCCESS; 176 176 177 - desc->stats.rx_errors++; 177 + hdlc->stats.rx_errors++; 178 178 dev_kfree_skb_any(skb); 179 179 return NET_RX_DROP; 180 180 } ··· 184 184 .open = x25_open, 185 185 .close = x25_close, 186 186 .ioctl = x25_ioctl, 187 + .netif_rx = x25_rx, 187 188 .module = THIS_MODULE, 188 189 }; 189 190 ··· 212 211 if (result) 213 212 return result; 214 213 215 - if ((result = attach_hdlc_protocol(dev, &proto, 216 - x25_rx, 0)) != 0) 214 + if ((result = attach_hdlc_protocol(dev, &proto, 0))) 217 215 return result; 218 216 dev->hard_start_xmit = x25_xmit; 219 217 dev->type = ARPHRD_X25;
+7 -18
include/linux/hdlc.h
··· 26 26 #include <linux/netdevice.h> 27 27 #include <linux/hdlc/ioctl.h> 28 28 29 - 30 - /* Used by all network devices here, pointed to by netdev_priv(dev) */ 31 - struct hdlc_device_desc { 32 - int (*netif_rx)(struct sk_buff *skb); 33 - struct net_device_stats stats; 34 - }; 35 - 36 29 /* This structure is a private property of HDLC protocols. 37 30 Hardware drivers have no interest here */ 38 31 ··· 37 44 void (*detach)(struct net_device *dev); 38 45 int (*ioctl)(struct net_device *dev, struct ifreq *ifr); 39 46 __be16 (*type_trans)(struct sk_buff *skb, struct net_device *dev); 47 + int (*netif_rx)(struct sk_buff *skb); 40 48 struct module *module; 41 49 struct hdlc_proto *next; /* next protocol in the list */ 42 50 }; 43 51 44 52 53 + /* Pointed to by dev->priv */ 45 54 typedef struct hdlc_device { 55 + struct net_device_stats stats; 46 56 /* used by HDLC layer to take control over HDLC device from hw driver*/ 47 57 int (*attach)(struct net_device *dev, 48 58 unsigned short encoding, unsigned short parity); ··· 79 83 80 84 struct net_device *alloc_hdlcdev(void *priv); 81 85 82 - 83 - static __inline__ struct hdlc_device_desc* dev_to_desc(struct net_device *dev) 86 + static inline struct hdlc_device* dev_to_hdlc(struct net_device *dev) 84 87 { 85 - return netdev_priv(dev); 88 + return dev->priv; 86 89 } 87 - 88 - static __inline__ hdlc_device* dev_to_hdlc(struct net_device *dev) 89 - { 90 - return netdev_priv(dev) + sizeof(struct hdlc_device_desc); 91 - } 92 - 93 90 94 91 static __inline__ void debug_frame(const struct sk_buff *skb) 95 92 { ··· 105 116 void hdlc_close(struct net_device *dev); 106 117 107 118 int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, 108 - int (*rx)(struct sk_buff *skb), size_t size); 119 + size_t size); 109 120 /* May be used by hardware driver to gain control over HDLC device */ 110 121 void detach_hdlc_protocol(struct net_device *dev); 111 122 112 123 static __inline__ struct net_device_stats *hdlc_stats(struct net_device *dev) 113 124 { 114 - return &dev_to_desc(dev)->stats; 125 + return &dev_to_hdlc(dev)->stats; 115 126 } 116 127 117 128