Skip to content

Commit 4710d80

Browse files
bhadramdavem330
authored andcommitted
6lowpan: mac802154: fix coding style issues
This patch fixed the coding style issues reported by checkpatch.pl following issues fixed: CHECK: Alignment should match open parenthesis WARNING: line over 80 characters CHECK: Blank lines aren't necessary before a close brace '}' WARNING: networking block comments don't use an empty /* line, use /* Comment... WARNING: Missing a blank line after declarations WARNING: networking block comments start with * on subsequent lines CHECK: braces {} should be used on all arms of this statement Signed-off-by: Varka Bhadram <[email protected]> Tested-by: Alexander Aring <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 46c9521 commit 4710d80

File tree

15 files changed

+153
-145
lines changed

15 files changed

+153
-145
lines changed

net/ieee802154/6lowpan_iphc.c

Lines changed: 52 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
* written by Alexander Smirnov <[email protected]>
44
*/
55

6-
/*
7-
* Based on patches from Jon Smirl <[email protected]>
6+
/* Based on patches from Jon Smirl <[email protected]>
87
* Copyright (c) 2011 Jon Smirl <[email protected]>
98
*
109
* This program is free software; you can redistribute it and/or modify
@@ -58,16 +57,15 @@
5857
#include <net/ipv6.h>
5958
#include <net/af_ieee802154.h>
6059

61-
/*
62-
* Uncompress address function for source and
60+
/* Uncompress address function for source and
6361
* destination address(non-multicast).
6462
*
6563
* address_mode is sam value or dam value.
6664
*/
6765
static int uncompress_addr(struct sk_buff *skb,
68-
struct in6_addr *ipaddr, const u8 address_mode,
69-
const u8 *lladdr, const u8 addr_type,
70-
const u8 addr_len)
66+
struct in6_addr *ipaddr, const u8 address_mode,
67+
const u8 *lladdr, const u8 addr_type,
68+
const u8 addr_len)
7169
{
7270
bool fail;
7371

@@ -140,13 +138,12 @@ static int uncompress_addr(struct sk_buff *skb,
140138
return 0;
141139
}
142140

143-
/*
144-
* Uncompress address function for source context
141+
/* Uncompress address function for source context
145142
* based address(non-multicast).
146143
*/
147144
static int uncompress_context_based_src_addr(struct sk_buff *skb,
148-
struct in6_addr *ipaddr,
149-
const u8 sam)
145+
struct in6_addr *ipaddr,
146+
const u8 sam)
150147
{
151148
switch (sam) {
152149
case LOWPAN_IPHC_ADDR_00:
@@ -175,13 +172,13 @@ static int uncompress_context_based_src_addr(struct sk_buff *skb,
175172
}
176173

177174
static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr,
178-
struct net_device *dev, skb_delivery_cb deliver_skb)
175+
struct net_device *dev, skb_delivery_cb deliver_skb)
179176
{
180177
struct sk_buff *new;
181178
int stat;
182179

183-
new = skb_copy_expand(skb, sizeof(struct ipv6hdr), skb_tailroom(skb),
184-
GFP_ATOMIC);
180+
new = skb_copy_expand(skb, sizeof(struct ipv6hdr),
181+
skb_tailroom(skb), GFP_ATOMIC);
185182
kfree_skb(skb);
186183

187184
if (!new)
@@ -196,7 +193,7 @@ static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr,
196193
new->dev = dev;
197194

198195
raw_dump_table(__func__, "raw skb data dump before receiving",
199-
new->data, new->len);
196+
new->data, new->len);
200197

201198
stat = deliver_skb(new, dev);
202199

@@ -210,8 +207,8 @@ static int skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr,
210207
*/
211208
static int
212209
lowpan_uncompress_multicast_daddr(struct sk_buff *skb,
213-
struct in6_addr *ipaddr,
214-
const u8 dam)
210+
struct in6_addr *ipaddr,
211+
const u8 dam)
215212
{
216213
bool fail;
217214

@@ -314,8 +311,7 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
314311
fail |= lowpan_fetch_skb(skb, &uh->check, 2);
315312
}
316313

317-
/*
318-
* UDP lenght needs to be infered from the lower layers
314+
/* UDP lenght needs to be infered from the lower layers
319315
* here, we obtain the hint from the remaining size of the
320316
* frame
321317
*/
@@ -338,16 +334,17 @@ uncompress_udp_header(struct sk_buff *skb, struct udphdr *uh)
338334
static const u8 lowpan_ttl_values[] = { 0, 1, 64, 255 };
339335

340336
int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
341-
const u8 *saddr, const u8 saddr_type, const u8 saddr_len,
342-
const u8 *daddr, const u8 daddr_type, const u8 daddr_len,
343-
u8 iphc0, u8 iphc1, skb_delivery_cb deliver_skb)
337+
const u8 *saddr, const u8 saddr_type,
338+
const u8 saddr_len, const u8 *daddr,
339+
const u8 daddr_type, const u8 daddr_len,
340+
u8 iphc0, u8 iphc1, skb_delivery_cb deliver_skb)
344341
{
345342
struct ipv6hdr hdr = {};
346343
u8 tmp, num_context = 0;
347344
int err;
348345

349346
raw_dump_table(__func__, "raw skb data dump uncompressed",
350-
skb->data, skb->len);
347+
skb->data, skb->len);
351348

352349
/* another if the CID flag is set */
353350
if (iphc1 & LOWPAN_IPHC_CID) {
@@ -360,8 +357,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
360357

361358
/* Traffic Class and Flow Label */
362359
switch ((iphc0 & LOWPAN_IPHC_TF) >> 3) {
363-
/*
364-
* Traffic Class and FLow Label carried in-line
360+
/* Traffic Class and FLow Label carried in-line
365361
* ECN + DSCP + 4-bit Pad + Flow Label (4 bytes)
366362
*/
367363
case 0: /* 00b */
@@ -374,8 +370,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
374370
hdr.flow_lbl[0] = ((tmp >> 2) & 0x30) | (tmp << 6) |
375371
(hdr.flow_lbl[0] & 0x0f);
376372
break;
377-
/*
378-
* Traffic class carried in-line
373+
/* Traffic class carried in-line
379374
* ECN + DSCP (1 byte), Flow Label is elided
380375
*/
381376
case 2: /* 10b */
@@ -385,8 +380,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
385380
hdr.priority = ((tmp >> 2) & 0x0f);
386381
hdr.flow_lbl[0] = ((tmp << 6) & 0xC0) | ((tmp >> 2) & 0x30);
387382
break;
388-
/*
389-
* Flow Label carried in-line
383+
/* Flow Label carried in-line
390384
* ECN + 2-bit Pad + Flow Label (3 bytes), DSCP is elided
391385
*/
392386
case 1: /* 01b */
@@ -415,9 +409,9 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
415409
}
416410

417411
/* Hop Limit */
418-
if ((iphc0 & 0x03) != LOWPAN_IPHC_TTL_I)
412+
if ((iphc0 & 0x03) != LOWPAN_IPHC_TTL_I) {
419413
hdr.hop_limit = lowpan_ttl_values[iphc0 & 0x03];
420-
else {
414+
} else {
421415
if (lowpan_fetch_skb_u8(skb, &(hdr.hop_limit)))
422416
goto drop;
423417
}
@@ -429,12 +423,12 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
429423
/* Source address context based uncompression */
430424
pr_debug("SAC bit is set. Handle context based source address.\n");
431425
err = uncompress_context_based_src_addr(
432-
skb, &hdr.saddr, tmp);
426+
skb, &hdr.saddr, tmp);
433427
} else {
434428
/* Source address uncompression */
435429
pr_debug("source address stateless compression\n");
436430
err = uncompress_addr(skb, &hdr.saddr, tmp, saddr,
437-
saddr_type, saddr_len);
431+
saddr_type, saddr_len);
438432
}
439433

440434
/* Check on error of previous branch */
@@ -457,9 +451,9 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
457451
}
458452
} else {
459453
err = uncompress_addr(skb, &hdr.daddr, tmp, daddr,
460-
daddr_type, daddr_len);
454+
daddr_type, daddr_len);
461455
pr_debug("dest: stateless compression mode %d dest %pI6c\n",
462-
tmp, &hdr.daddr);
456+
tmp, &hdr.daddr);
463457
if (err)
464458
goto drop;
465459
}
@@ -468,11 +462,11 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
468462
if (iphc0 & LOWPAN_IPHC_NH_C) {
469463
struct udphdr uh;
470464
struct sk_buff *new;
465+
471466
if (uncompress_udp_header(skb, &uh))
472467
goto drop;
473468

474-
/*
475-
* replace the compressed UDP head by the uncompressed UDP
469+
/* replace the compressed UDP head by the uncompressed UDP
476470
* header
477471
*/
478472
new = skb_copy_expand(skb, sizeof(struct udphdr),
@@ -489,7 +483,7 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
489483
skb_copy_to_linear_data(skb, &uh, sizeof(struct udphdr));
490484

491485
raw_dump_table(__func__, "raw UDP header dump",
492-
(u8 *)&uh, sizeof(uh));
486+
(u8 *)&uh, sizeof(uh));
493487

494488
hdr.nexthdr = UIP_PROTO_UDP;
495489
}
@@ -504,8 +498,8 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
504498
hdr.version, ntohs(hdr.payload_len), hdr.nexthdr,
505499
hdr.hop_limit, &hdr.daddr);
506500

507-
raw_dump_table(__func__, "raw header dump", (u8 *)&hdr,
508-
sizeof(hdr));
501+
raw_dump_table(__func__, "raw header dump",
502+
(u8 *)&hdr, sizeof(hdr));
509503

510504
return skb_deliver(skb, &hdr, dev, deliver_skb);
511505

@@ -516,8 +510,8 @@ int lowpan_process_data(struct sk_buff *skb, struct net_device *dev,
516510
EXPORT_SYMBOL_GPL(lowpan_process_data);
517511

518512
static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift,
519-
const struct in6_addr *ipaddr,
520-
const unsigned char *lladdr)
513+
const struct in6_addr *ipaddr,
514+
const unsigned char *lladdr)
521515
{
522516
u8 val = 0;
523517

@@ -530,14 +524,14 @@ static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift,
530524
*hc06_ptr += 2;
531525
val = 2; /* 16-bits */
532526
raw_dump_inline(NULL, "Compressed ipv6 addr is (16 bits)",
533-
*hc06_ptr - 2, 2);
527+
*hc06_ptr - 2, 2);
534528
} else {
535529
/* do not compress IID => xxxx::IID */
536530
memcpy(*hc06_ptr, &ipaddr->s6_addr16[4], 8);
537531
*hc06_ptr += 8;
538532
val = 1; /* 64-bits */
539533
raw_dump_inline(NULL, "Compressed ipv6 addr is (64 bits)",
540-
*hc06_ptr - 8, 8);
534+
*hc06_ptr - 8, 8);
541535
}
542536

543537
return rol8(val, shift);
@@ -601,8 +595,8 @@ static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb)
601595
}
602596

603597
int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
604-
unsigned short type, const void *_daddr,
605-
const void *_saddr, unsigned int len)
598+
unsigned short type, const void *_daddr,
599+
const void *_saddr, unsigned int len)
606600
{
607601
u8 tmp, iphc0, iphc1, *hc06_ptr;
608602
struct ipv6hdr *hdr;
@@ -616,14 +610,13 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
616610

617611
pr_debug("IPv6 header dump:\n\tversion = %d\n\tlength = %d\n"
618612
"\tnexthdr = 0x%02x\n\thop_lim = %d\n\tdest = %pI6c\n",
619-
hdr->version, ntohs(hdr->payload_len), hdr->nexthdr,
620-
hdr->hop_limit, &hdr->daddr);
613+
hdr->version, ntohs(hdr->payload_len), hdr->nexthdr,
614+
hdr->hop_limit, &hdr->daddr);
621615

622616
raw_dump_table(__func__, "raw skb network header dump",
623-
skb_network_header(skb), sizeof(struct ipv6hdr));
617+
skb_network_header(skb), sizeof(struct ipv6hdr));
624618

625-
/*
626-
* As we copy some bit-length fields, in the IPHC encoding bytes,
619+
/* As we copy some bit-length fields, in the IPHC encoding bytes,
627620
* we sometimes use |=
628621
* If the field is 0, and the current bit value in memory is 1,
629622
* this does not work. We therefore reset the IPHC encoding here
@@ -639,11 +632,10 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
639632
(unsigned char *)_daddr, IEEE802154_ADDR_LEN);
640633

641634
raw_dump_table(__func__,
642-
"sending raw skb network uncompressed packet",
643-
skb->data, skb->len);
635+
"sending raw skb network uncompressed packet",
636+
skb->data, skb->len);
644637

645-
/*
646-
* Traffic class, flow label
638+
/* Traffic class, flow label
647639
* If flow label is 0, compress it. If traffic class is 0, compress it
648640
* We have to process both in the same time as the offset of traffic
649641
* class depends on the presence of version and flow label
@@ -654,11 +646,11 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
654646
tmp = ((tmp & 0x03) << 6) | (tmp >> 2);
655647

656648
if (((hdr->flow_lbl[0] & 0x0F) == 0) &&
657-
(hdr->flow_lbl[1] == 0) && (hdr->flow_lbl[2] == 0)) {
649+
(hdr->flow_lbl[1] == 0) && (hdr->flow_lbl[2] == 0)) {
658650
/* flow label can be compressed */
659651
iphc0 |= LOWPAN_IPHC_FL_C;
660652
if ((hdr->priority == 0) &&
661-
((hdr->flow_lbl[0] & 0xF0) == 0)) {
653+
((hdr->flow_lbl[0] & 0xF0) == 0)) {
662654
/* compress (elide) all */
663655
iphc0 |= LOWPAN_IPHC_TC_C;
664656
} else {
@@ -669,7 +661,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
669661
} else {
670662
/* Flow label cannot be compressed */
671663
if ((hdr->priority == 0) &&
672-
((hdr->flow_lbl[0] & 0xF0) == 0)) {
664+
((hdr->flow_lbl[0] & 0xF0) == 0)) {
673665
/* compress only traffic class */
674666
iphc0 |= LOWPAN_IPHC_TC_C;
675667
*hc06_ptr = (tmp & 0xc0) | (hdr->flow_lbl[0] & 0x0F);
@@ -695,8 +687,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
695687
hc06_ptr += 1;
696688
}
697689

698-
/*
699-
* Hop limit
690+
/* Hop limit
700691
* if 1: compress, encoding is 01
701692
* if 64: compress, encoding is 10
702693
* if 255: compress, encoding is 11
@@ -793,7 +784,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
793784
pr_debug("header len %d skb %u\n", (int)(hc06_ptr - head), skb->len);
794785

795786
raw_dump_table(__func__, "raw skb data dump compressed",
796-
skb->data, skb->len);
787+
skb->data, skb->len);
797788
return 0;
798789
}
799790
EXPORT_SYMBOL_GPL(lowpan_header_compress);

0 commit comments

Comments
 (0)