aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHimangi Saraogi <himangi774@gmail.com>2014-08-09 12:47:16 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-11 15:19:53 -0400
commit3fadb06daef958d2ae2d3be363a0cfaa92008b52 (patch)
tree559b89b587ca5f428b2c243ab177077c1ccc89b1
parent61ecba6422a34aaa1956119607a25ff57c1c61a4 (diff)
hdlc: Remove typedefs from struct names
The Linux kernel coding style guidelines suggest not using typedefs for structure types. This patch gets rid of the typedefs for fr_hdr and pvc_device. Also, the names of the structs are changed to drop the _t, to make the name look less typedef-like. The following Coccinelle semantic patch detects the case fr_hdr and a similar one detects the case for pvc_device. @tn1@ type td; @@ typedef struct { ... } td; @script:python tf@ td << tn1.td; tdres; @@ coccinelle.tdres = td; @@ type tn1.td; identifier tf.tdres; @@ -typedef struct + tdres { ... } -td ; @@ type tn1.td; identifier tf.tdres; @@ -td + struct tdres Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/wan/hdlc_fr.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 7cc64eac0fa3..e5c7e6165a4b 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -90,7 +90,7 @@
90#define LMI_ANSI_LENGTH 14 90#define LMI_ANSI_LENGTH 14
91 91
92 92
93typedef struct { 93struct fr_hdr {
94#if defined(__LITTLE_ENDIAN_BITFIELD) 94#if defined(__LITTLE_ENDIAN_BITFIELD)
95 unsigned ea1: 1; 95 unsigned ea1: 1;
96 unsigned cr: 1; 96 unsigned cr: 1;
@@ -112,14 +112,14 @@ typedef struct {
112 unsigned de: 1; 112 unsigned de: 1;
113 unsigned ea2: 1; 113 unsigned ea2: 1;
114#endif 114#endif
115}__packed fr_hdr; 115} __packed;
116 116
117 117
118typedef struct pvc_device_struct { 118struct pvc_device {
119 struct net_device *frad; 119 struct net_device *frad;
120 struct net_device *main; 120 struct net_device *main;
121 struct net_device *ether; /* bridged Ethernet interface */ 121 struct net_device *ether; /* bridged Ethernet interface */
122 struct pvc_device_struct *next; /* Sorted in ascending DLCI order */ 122 struct pvc_device *next; /* Sorted in ascending DLCI order */
123 int dlci; 123 int dlci;
124 int open_count; 124 int open_count;
125 125
@@ -132,11 +132,11 @@ typedef struct pvc_device_struct {
132 unsigned int becn: 1; 132 unsigned int becn: 1;
133 unsigned int bandwidth; /* Cisco LMI reporting only */ 133 unsigned int bandwidth; /* Cisco LMI reporting only */
134 }state; 134 }state;
135}pvc_device; 135};
136 136
137struct frad_state { 137struct frad_state {
138 fr_proto settings; 138 fr_proto settings;
139 pvc_device *first_pvc; 139 struct pvc_device *first_pvc;
140 int dce_pvc_count; 140 int dce_pvc_count;
141 141
142 struct timer_list timer; 142 struct timer_list timer;
@@ -174,9 +174,9 @@ static inline struct frad_state* state(hdlc_device *hdlc)
174} 174}
175 175
176 176
177static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci) 177static inline struct pvc_device *find_pvc(hdlc_device *hdlc, u16 dlci)
178{ 178{
179 pvc_device *pvc = state(hdlc)->first_pvc; 179 struct pvc_device *pvc = state(hdlc)->first_pvc;
180 180
181 while (pvc) { 181 while (pvc) {
182 if (pvc->dlci == dlci) 182 if (pvc->dlci == dlci)
@@ -190,10 +190,10 @@ static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci)
190} 190}
191 191
192 192
193static pvc_device* add_pvc(struct net_device *dev, u16 dlci) 193static struct pvc_device *add_pvc(struct net_device *dev, u16 dlci)
194{ 194{
195 hdlc_device *hdlc = dev_to_hdlc(dev); 195 hdlc_device *hdlc = dev_to_hdlc(dev);
196 pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc; 196 struct pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc;
197 197
198 while (*pvc_p) { 198 while (*pvc_p) {
199 if ((*pvc_p)->dlci == dlci) 199 if ((*pvc_p)->dlci == dlci)
@@ -203,7 +203,7 @@ static pvc_device* add_pvc(struct net_device *dev, u16 dlci)
203 pvc_p = &(*pvc_p)->next; 203 pvc_p = &(*pvc_p)->next;
204 } 204 }
205 205
206 pvc = kzalloc(sizeof(pvc_device), GFP_ATOMIC); 206 pvc = kzalloc(sizeof(*pvc), GFP_ATOMIC);
207#ifdef DEBUG_PVC 207#ifdef DEBUG_PVC
208 printk(KERN_DEBUG "add_pvc: allocated pvc %p, frad %p\n", pvc, dev); 208 printk(KERN_DEBUG "add_pvc: allocated pvc %p, frad %p\n", pvc, dev);
209#endif 209#endif
@@ -218,13 +218,13 @@ static pvc_device* add_pvc(struct net_device *dev, u16 dlci)
218} 218}
219 219
220 220
221static inline int pvc_is_used(pvc_device *pvc) 221static inline int pvc_is_used(struct pvc_device *pvc)
222{ 222{
223 return pvc->main || pvc->ether; 223 return pvc->main || pvc->ether;
224} 224}
225 225
226 226
227static inline void pvc_carrier(int on, pvc_device *pvc) 227static inline void pvc_carrier(int on, struct pvc_device *pvc)
228{ 228{
229 if (on) { 229 if (on) {
230 if (pvc->main) 230 if (pvc->main)
@@ -246,11 +246,11 @@ static inline void pvc_carrier(int on, pvc_device *pvc)
246 246
247static inline void delete_unused_pvcs(hdlc_device *hdlc) 247static inline void delete_unused_pvcs(hdlc_device *hdlc)
248{ 248{
249 pvc_device **pvc_p = &state(hdlc)->first_pvc; 249 struct pvc_device **pvc_p = &state(hdlc)->first_pvc;
250 250
251 while (*pvc_p) { 251 while (*pvc_p) {
252 if (!pvc_is_used(*pvc_p)) { 252 if (!pvc_is_used(*pvc_p)) {
253 pvc_device *pvc = *pvc_p; 253 struct pvc_device *pvc = *pvc_p;
254#ifdef DEBUG_PVC 254#ifdef DEBUG_PVC
255 printk(KERN_DEBUG "freeing unused pvc: %p\n", pvc); 255 printk(KERN_DEBUG "freeing unused pvc: %p\n", pvc);
256#endif 256#endif
@@ -263,7 +263,8 @@ static inline void delete_unused_pvcs(hdlc_device *hdlc)
263} 263}
264 264
265 265
266static inline struct net_device** get_dev_p(pvc_device *pvc, int type) 266static inline struct net_device **get_dev_p(struct pvc_device *pvc,
267 int type)
267{ 268{
268 if (type == ARPHRD_ETHER) 269 if (type == ARPHRD_ETHER)
269 return &pvc->ether; 270 return &pvc->ether;
@@ -342,7 +343,7 @@ static int fr_hard_header(struct sk_buff **skb_p, u16 dlci)
342 343
343static int pvc_open(struct net_device *dev) 344static int pvc_open(struct net_device *dev)
344{ 345{
345 pvc_device *pvc = dev->ml_priv; 346 struct pvc_device *pvc = dev->ml_priv;
346 347
347 if ((pvc->frad->flags & IFF_UP) == 0) 348 if ((pvc->frad->flags & IFF_UP) == 0)
348 return -EIO; /* Frad must be UP in order to activate PVC */ 349 return -EIO; /* Frad must be UP in order to activate PVC */
@@ -362,7 +363,7 @@ static int pvc_open(struct net_device *dev)
362 363
363static int pvc_close(struct net_device *dev) 364static int pvc_close(struct net_device *dev)
364{ 365{
365 pvc_device *pvc = dev->ml_priv; 366 struct pvc_device *pvc = dev->ml_priv;
366 367
367 if (--pvc->open_count == 0) { 368 if (--pvc->open_count == 0) {
368 hdlc_device *hdlc = dev_to_hdlc(pvc->frad); 369 hdlc_device *hdlc = dev_to_hdlc(pvc->frad);
@@ -381,7 +382,7 @@ static int pvc_close(struct net_device *dev)
381 382
382static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 383static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
383{ 384{
384 pvc_device *pvc = dev->ml_priv; 385 struct pvc_device *pvc = dev->ml_priv;
385 fr_proto_pvc_info info; 386 fr_proto_pvc_info info;
386 387
387 if (ifr->ifr_settings.type == IF_GET_PROTO) { 388 if (ifr->ifr_settings.type == IF_GET_PROTO) {
@@ -409,7 +410,7 @@ static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
409 410
410static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev) 411static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
411{ 412{
412 pvc_device *pvc = dev->ml_priv; 413 struct pvc_device *pvc = dev->ml_priv;
413 414
414 if (pvc->state.active) { 415 if (pvc->state.active) {
415 if (dev->type == ARPHRD_ETHER) { 416 if (dev->type == ARPHRD_ETHER) {
@@ -444,7 +445,7 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
444 return NETDEV_TX_OK; 445 return NETDEV_TX_OK;
445} 446}
446 447
447static inline void fr_log_dlci_active(pvc_device *pvc) 448static inline void fr_log_dlci_active(struct pvc_device *pvc)
448{ 449{
449 netdev_info(pvc->frad, "DLCI %d [%s%s%s]%s %s\n", 450 netdev_info(pvc->frad, "DLCI %d [%s%s%s]%s %s\n",
450 pvc->dlci, 451 pvc->dlci,
@@ -469,7 +470,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)
469{ 470{
470 hdlc_device *hdlc = dev_to_hdlc(dev); 471 hdlc_device *hdlc = dev_to_hdlc(dev);
471 struct sk_buff *skb; 472 struct sk_buff *skb;
472 pvc_device *pvc = state(hdlc)->first_pvc; 473 struct pvc_device *pvc = state(hdlc)->first_pvc;
473 int lmi = state(hdlc)->settings.lmi; 474 int lmi = state(hdlc)->settings.lmi;
474 int dce = state(hdlc)->settings.dce; 475 int dce = state(hdlc)->settings.dce;
475 int len = lmi == LMI_ANSI ? LMI_ANSI_LENGTH : LMI_CCITT_CISCO_LENGTH; 476 int len = lmi == LMI_ANSI ? LMI_ANSI_LENGTH : LMI_CCITT_CISCO_LENGTH;
@@ -566,7 +567,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)
566static void fr_set_link_state(int reliable, struct net_device *dev) 567static void fr_set_link_state(int reliable, struct net_device *dev)
567{ 568{
568 hdlc_device *hdlc = dev_to_hdlc(dev); 569 hdlc_device *hdlc = dev_to_hdlc(dev);
569 pvc_device *pvc = state(hdlc)->first_pvc; 570 struct pvc_device *pvc = state(hdlc)->first_pvc;
570 571
571 state(hdlc)->reliable = reliable; 572 state(hdlc)->reliable = reliable;
572 if (reliable) { 573 if (reliable) {
@@ -652,7 +653,7 @@ static void fr_timer(unsigned long arg)
652static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb) 653static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
653{ 654{
654 hdlc_device *hdlc = dev_to_hdlc(dev); 655 hdlc_device *hdlc = dev_to_hdlc(dev);
655 pvc_device *pvc; 656 struct pvc_device *pvc;
656 u8 rxseq, txseq; 657 u8 rxseq, txseq;
657 int lmi = state(hdlc)->settings.lmi; 658 int lmi = state(hdlc)->settings.lmi;
658 int dce = state(hdlc)->settings.dce; 659 int dce = state(hdlc)->settings.dce;
@@ -869,10 +870,10 @@ static int fr_rx(struct sk_buff *skb)
869{ 870{
870 struct net_device *frad = skb->dev; 871 struct net_device *frad = skb->dev;
871 hdlc_device *hdlc = dev_to_hdlc(frad); 872 hdlc_device *hdlc = dev_to_hdlc(frad);
872 fr_hdr *fh = (fr_hdr*)skb->data; 873 struct fr_hdr *fh = (struct fr_hdr *)skb->data;
873 u8 *data = skb->data; 874 u8 *data = skb->data;
874 u16 dlci; 875 u16 dlci;
875 pvc_device *pvc; 876 struct pvc_device *pvc;
876 struct net_device *dev = NULL; 877 struct net_device *dev = NULL;
877 878
878 if (skb->len <= 4 || fh->ea1 || data[2] != FR_UI) 879 if (skb->len <= 4 || fh->ea1 || data[2] != FR_UI)
@@ -1028,7 +1029,7 @@ static void fr_stop(struct net_device *dev)
1028static void fr_close(struct net_device *dev) 1029static void fr_close(struct net_device *dev)
1029{ 1030{
1030 hdlc_device *hdlc = dev_to_hdlc(dev); 1031 hdlc_device *hdlc = dev_to_hdlc(dev);
1031 pvc_device *pvc = state(hdlc)->first_pvc; 1032 struct pvc_device *pvc = state(hdlc)->first_pvc;
1032 1033
1033 while (pvc) { /* Shutdown all PVCs for this FRAD */ 1034 while (pvc) { /* Shutdown all PVCs for this FRAD */
1034 if (pvc->main) 1035 if (pvc->main)
@@ -1060,7 +1061,7 @@ static const struct net_device_ops pvc_ops = {
1060static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) 1061static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
1061{ 1062{
1062 hdlc_device *hdlc = dev_to_hdlc(frad); 1063 hdlc_device *hdlc = dev_to_hdlc(frad);
1063 pvc_device *pvc; 1064 struct pvc_device *pvc;
1064 struct net_device *dev; 1065 struct net_device *dev;
1065 int used; 1066 int used;
1066 1067
@@ -1117,7 +1118,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
1117 1118
1118static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type) 1119static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
1119{ 1120{
1120 pvc_device *pvc; 1121 struct pvc_device *pvc;
1121 struct net_device *dev; 1122 struct net_device *dev;
1122 1123
1123 if ((pvc = find_pvc(hdlc, dlci)) == NULL) 1124 if ((pvc = find_pvc(hdlc, dlci)) == NULL)
@@ -1145,13 +1146,13 @@ static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
1145static void fr_destroy(struct net_device *frad) 1146static void fr_destroy(struct net_device *frad)
1146{ 1147{
1147 hdlc_device *hdlc = dev_to_hdlc(frad); 1148 hdlc_device *hdlc = dev_to_hdlc(frad);
1148 pvc_device *pvc = state(hdlc)->first_pvc; 1149 struct pvc_device *pvc = state(hdlc)->first_pvc;
1149 state(hdlc)->first_pvc = NULL; /* All PVCs destroyed */ 1150 state(hdlc)->first_pvc = NULL; /* All PVCs destroyed */
1150 state(hdlc)->dce_pvc_count = 0; 1151 state(hdlc)->dce_pvc_count = 0;
1151 state(hdlc)->dce_changed = 1; 1152 state(hdlc)->dce_changed = 1;
1152 1153
1153 while (pvc) { 1154 while (pvc) {
1154 pvc_device *next = pvc->next; 1155 struct pvc_device *next = pvc->next;
1155 /* destructors will free_netdev() main and ether */ 1156 /* destructors will free_netdev() main and ether */
1156 if (pvc->main) 1157 if (pvc->main)
1157 unregister_netdevice(pvc->main); 1158 unregister_netdevice(pvc->main);