diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2011-03-21 09:19:58 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-03-31 13:22:55 -0400 |
commit | 3aad75a128e2f2b8da31de1df4b9b9b4a8f65c66 (patch) | |
tree | 195fc4178c30a517862d29bb002f65ef49025c76 /net/bluetooth | |
parent | a3d9bd4c00f13defd4c0fdcf8b47f8764a69e54d (diff) |
Bluetooth: Fix checkpatch errors and some code style issues in bnep
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/bnep/bnep.h | 146 | ||||
-rw-r--r-- | net/bluetooth/bnep/core.c | 37 |
2 files changed, 94 insertions, 89 deletions
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h index 70672544db86..d768e0434ed8 100644 --- a/net/bluetooth/bnep/bnep.h +++ b/net/bluetooth/bnep/bnep.h | |||
@@ -23,88 +23,88 @@ | |||
23 | #include <linux/crc32.h> | 23 | #include <linux/crc32.h> |
24 | #include <net/bluetooth/bluetooth.h> | 24 | #include <net/bluetooth/bluetooth.h> |
25 | 25 | ||
26 | // Limits | 26 | /* Limits */ |
27 | #define BNEP_MAX_PROTO_FILTERS 5 | 27 | #define BNEP_MAX_PROTO_FILTERS 5 |
28 | #define BNEP_MAX_MULTICAST_FILTERS 20 | 28 | #define BNEP_MAX_MULTICAST_FILTERS 20 |
29 | 29 | ||
30 | // UUIDs | 30 | /* UUIDs */ |
31 | #define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB | 31 | #define BNEP_BASE_UUID 0x0000000000001000800000805F9B34FB |
32 | #define BNEP_UUID16 0x02 | 32 | #define BNEP_UUID16 0x02 |
33 | #define BNEP_UUID32 0x04 | 33 | #define BNEP_UUID32 0x04 |
34 | #define BNEP_UUID128 0x16 | 34 | #define BNEP_UUID128 0x16 |
35 | 35 | ||
36 | #define BNEP_SVC_PANU 0x1115 | 36 | #define BNEP_SVC_PANU 0x1115 |
37 | #define BNEP_SVC_NAP 0x1116 | 37 | #define BNEP_SVC_NAP 0x1116 |
38 | #define BNEP_SVC_GN 0x1117 | 38 | #define BNEP_SVC_GN 0x1117 |
39 | 39 | ||
40 | // Packet types | 40 | /* Packet types */ |
41 | #define BNEP_GENERAL 0x00 | 41 | #define BNEP_GENERAL 0x00 |
42 | #define BNEP_CONTROL 0x01 | 42 | #define BNEP_CONTROL 0x01 |
43 | #define BNEP_COMPRESSED 0x02 | 43 | #define BNEP_COMPRESSED 0x02 |
44 | #define BNEP_COMPRESSED_SRC_ONLY 0x03 | 44 | #define BNEP_COMPRESSED_SRC_ONLY 0x03 |
45 | #define BNEP_COMPRESSED_DST_ONLY 0x04 | 45 | #define BNEP_COMPRESSED_DST_ONLY 0x04 |
46 | 46 | ||
47 | // Control types | 47 | /* Control types */ |
48 | #define BNEP_CMD_NOT_UNDERSTOOD 0x00 | 48 | #define BNEP_CMD_NOT_UNDERSTOOD 0x00 |
49 | #define BNEP_SETUP_CONN_REQ 0x01 | 49 | #define BNEP_SETUP_CONN_REQ 0x01 |
50 | #define BNEP_SETUP_CONN_RSP 0x02 | 50 | #define BNEP_SETUP_CONN_RSP 0x02 |
51 | #define BNEP_FILTER_NET_TYPE_SET 0x03 | 51 | #define BNEP_FILTER_NET_TYPE_SET 0x03 |
52 | #define BNEP_FILTER_NET_TYPE_RSP 0x04 | 52 | #define BNEP_FILTER_NET_TYPE_RSP 0x04 |
53 | #define BNEP_FILTER_MULTI_ADDR_SET 0x05 | 53 | #define BNEP_FILTER_MULTI_ADDR_SET 0x05 |
54 | #define BNEP_FILTER_MULTI_ADDR_RSP 0x06 | 54 | #define BNEP_FILTER_MULTI_ADDR_RSP 0x06 |
55 | 55 | ||
56 | // Extension types | 56 | /* Extension types */ |
57 | #define BNEP_EXT_CONTROL 0x00 | 57 | #define BNEP_EXT_CONTROL 0x00 |
58 | 58 | ||
59 | // Response messages | 59 | /* Response messages */ |
60 | #define BNEP_SUCCESS 0x00 | 60 | #define BNEP_SUCCESS 0x00 |
61 | 61 | ||
62 | #define BNEP_CONN_INVALID_DST 0x01 | 62 | #define BNEP_CONN_INVALID_DST 0x01 |
63 | #define BNEP_CONN_INVALID_SRC 0x02 | 63 | #define BNEP_CONN_INVALID_SRC 0x02 |
64 | #define BNEP_CONN_INVALID_SVC 0x03 | 64 | #define BNEP_CONN_INVALID_SVC 0x03 |
65 | #define BNEP_CONN_NOT_ALLOWED 0x04 | 65 | #define BNEP_CONN_NOT_ALLOWED 0x04 |
66 | 66 | ||
67 | #define BNEP_FILTER_UNSUPPORTED_REQ 0x01 | 67 | #define BNEP_FILTER_UNSUPPORTED_REQ 0x01 |
68 | #define BNEP_FILTER_INVALID_RANGE 0x02 | 68 | #define BNEP_FILTER_INVALID_RANGE 0x02 |
69 | #define BNEP_FILTER_INVALID_MCADDR 0x02 | 69 | #define BNEP_FILTER_INVALID_MCADDR 0x02 |
70 | #define BNEP_FILTER_LIMIT_REACHED 0x03 | 70 | #define BNEP_FILTER_LIMIT_REACHED 0x03 |
71 | #define BNEP_FILTER_DENIED_SECURITY 0x04 | 71 | #define BNEP_FILTER_DENIED_SECURITY 0x04 |
72 | 72 | ||
73 | // L2CAP settings | 73 | /* L2CAP settings */ |
74 | #define BNEP_MTU 1691 | 74 | #define BNEP_MTU 1691 |
75 | #define BNEP_PSM 0x0f | 75 | #define BNEP_PSM 0x0f |
76 | #define BNEP_FLUSH_TO 0xffff | 76 | #define BNEP_FLUSH_TO 0xffff |
77 | #define BNEP_CONNECT_TO 15 | 77 | #define BNEP_CONNECT_TO 15 |
78 | #define BNEP_FILTER_TO 15 | 78 | #define BNEP_FILTER_TO 15 |
79 | 79 | ||
80 | // Headers | 80 | /* Headers */ |
81 | #define BNEP_TYPE_MASK 0x7f | 81 | #define BNEP_TYPE_MASK 0x7f |
82 | #define BNEP_EXT_HEADER 0x80 | 82 | #define BNEP_EXT_HEADER 0x80 |
83 | 83 | ||
84 | struct bnep_setup_conn_req { | 84 | struct bnep_setup_conn_req { |
85 | __u8 type; | 85 | __u8 type; |
86 | __u8 ctrl; | 86 | __u8 ctrl; |
87 | __u8 uuid_size; | 87 | __u8 uuid_size; |
88 | __u8 service[0]; | 88 | __u8 service[0]; |
89 | } __packed; | 89 | } __packed; |
90 | 90 | ||
91 | struct bnep_set_filter_req { | 91 | struct bnep_set_filter_req { |
92 | __u8 type; | 92 | __u8 type; |
93 | __u8 ctrl; | 93 | __u8 ctrl; |
94 | __be16 len; | 94 | __be16 len; |
95 | __u8 list[0]; | 95 | __u8 list[0]; |
96 | } __packed; | 96 | } __packed; |
97 | 97 | ||
98 | struct bnep_control_rsp { | 98 | struct bnep_control_rsp { |
99 | __u8 type; | 99 | __u8 type; |
100 | __u8 ctrl; | 100 | __u8 ctrl; |
101 | __be16 resp; | 101 | __be16 resp; |
102 | } __packed; | 102 | } __packed; |
103 | 103 | ||
104 | struct bnep_ext_hdr { | 104 | struct bnep_ext_hdr { |
105 | __u8 type; | 105 | __u8 type; |
106 | __u8 len; | 106 | __u8 len; |
107 | __u8 data[0]; | 107 | __u8 data[0]; |
108 | } __packed; | 108 | } __packed; |
109 | 109 | ||
110 | /* BNEP ioctl defines */ | 110 | /* BNEP ioctl defines */ |
@@ -114,10 +114,10 @@ struct bnep_ext_hdr { | |||
114 | #define BNEPGETCONNINFO _IOR('B', 211, int) | 114 | #define BNEPGETCONNINFO _IOR('B', 211, int) |
115 | 115 | ||
116 | struct bnep_connadd_req { | 116 | struct bnep_connadd_req { |
117 | int sock; // Connected socket | 117 | int sock; /* Connected socket */ |
118 | __u32 flags; | 118 | __u32 flags; |
119 | __u16 role; | 119 | __u16 role; |
120 | char device[16]; // Name of the Ethernet device | 120 | char device[16]; /* Name of the Ethernet device */ |
121 | }; | 121 | }; |
122 | 122 | ||
123 | struct bnep_conndel_req { | 123 | struct bnep_conndel_req { |
@@ -148,7 +148,7 @@ int bnep_del_connection(struct bnep_conndel_req *req); | |||
148 | int bnep_get_connlist(struct bnep_connlist_req *req); | 148 | int bnep_get_connlist(struct bnep_connlist_req *req); |
149 | int bnep_get_conninfo(struct bnep_conninfo *ci); | 149 | int bnep_get_conninfo(struct bnep_conninfo *ci); |
150 | 150 | ||
151 | // BNEP sessions | 151 | /* BNEP sessions */ |
152 | struct bnep_session { | 152 | struct bnep_session { |
153 | struct list_head list; | 153 | struct list_head list; |
154 | 154 | ||
@@ -173,7 +173,7 @@ void bnep_sock_cleanup(void); | |||
173 | 173 | ||
174 | static inline int bnep_mc_hash(__u8 *addr) | 174 | static inline int bnep_mc_hash(__u8 *addr) |
175 | { | 175 | { |
176 | return (crc32_be(~0, addr, ETH_ALEN) >> 26); | 176 | return crc32_be(~0, addr, ETH_ALEN) >> 26; |
177 | } | 177 | } |
178 | 178 | ||
179 | #endif | 179 | #endif |
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 940b4e129741..0a2e76bde542 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
@@ -131,7 +131,8 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len | |||
131 | return -EILSEQ; | 131 | return -EILSEQ; |
132 | 132 | ||
133 | n = get_unaligned_be16(data); | 133 | n = get_unaligned_be16(data); |
134 | data++; len -= 2; | 134 | data++; |
135 | len -= 2; | ||
135 | 136 | ||
136 | if (len < n) | 137 | if (len < n) |
137 | return -EILSEQ; | 138 | return -EILSEQ; |
@@ -176,7 +177,8 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len) | |||
176 | return -EILSEQ; | 177 | return -EILSEQ; |
177 | 178 | ||
178 | n = get_unaligned_be16(data); | 179 | n = get_unaligned_be16(data); |
179 | data += 2; len -= 2; | 180 | data += 2; |
181 | len -= 2; | ||
180 | 182 | ||
181 | if (len < n) | 183 | if (len < n) |
182 | return -EILSEQ; | 184 | return -EILSEQ; |
@@ -198,8 +200,10 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len) | |||
198 | for (; n > 0; n--) { | 200 | for (; n > 0; n--) { |
199 | u8 a1[6], *a2; | 201 | u8 a1[6], *a2; |
200 | 202 | ||
201 | memcpy(a1, data, ETH_ALEN); data += ETH_ALEN; | 203 | memcpy(a1, data, ETH_ALEN); |
202 | a2 = data; data += ETH_ALEN; | 204 | data += ETH_ALEN; |
205 | a2 = data; | ||
206 | data += ETH_ALEN; | ||
203 | 207 | ||
204 | BT_DBG("mc filter %s -> %s", | 208 | BT_DBG("mc filter %s -> %s", |
205 | batostr((void *) a1), batostr((void *) a2)); | 209 | batostr((void *) a1), batostr((void *) a2)); |
@@ -231,7 +235,8 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len) | |||
231 | u8 cmd = *(u8 *)data; | 235 | u8 cmd = *(u8 *)data; |
232 | int err = 0; | 236 | int err = 0; |
233 | 237 | ||
234 | data++; len--; | 238 | data++; |
239 | len--; | ||
235 | 240 | ||
236 | switch (cmd) { | 241 | switch (cmd) { |
237 | case BNEP_CMD_NOT_UNDERSTOOD: | 242 | case BNEP_CMD_NOT_UNDERSTOOD: |
@@ -315,7 +320,8 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb) | |||
315 | 320 | ||
316 | dev->stats.rx_bytes += skb->len; | 321 | dev->stats.rx_bytes += skb->len; |
317 | 322 | ||
318 | type = *(u8 *) skb->data; skb_pull(skb, 1); | 323 | type = *(u8 *) skb->data; |
324 | skb_pull(skb, 1); | ||
319 | 325 | ||
320 | if ((type & BNEP_TYPE_MASK) >= sizeof(__bnep_rx_hlen)) | 326 | if ((type & BNEP_TYPE_MASK) >= sizeof(__bnep_rx_hlen)) |
321 | goto badframe; | 327 | goto badframe; |
@@ -370,14 +376,14 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb) | |||
370 | 376 | ||
371 | case BNEP_COMPRESSED_DST_ONLY: | 377 | case BNEP_COMPRESSED_DST_ONLY: |
372 | memcpy(__skb_put(nskb, ETH_ALEN), skb_mac_header(skb), | 378 | memcpy(__skb_put(nskb, ETH_ALEN), skb_mac_header(skb), |
373 | ETH_ALEN); | 379 | ETH_ALEN); |
374 | memcpy(__skb_put(nskb, ETH_ALEN + 2), s->eh.h_source, | 380 | memcpy(__skb_put(nskb, ETH_ALEN + 2), s->eh.h_source, |
375 | ETH_ALEN + 2); | 381 | ETH_ALEN + 2); |
376 | break; | 382 | break; |
377 | 383 | ||
378 | case BNEP_GENERAL: | 384 | case BNEP_GENERAL: |
379 | memcpy(__skb_put(nskb, ETH_ALEN * 2), skb_mac_header(skb), | 385 | memcpy(__skb_put(nskb, ETH_ALEN * 2), skb_mac_header(skb), |
380 | ETH_ALEN * 2); | 386 | ETH_ALEN * 2); |
381 | put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2)); | 387 | put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2)); |
382 | break; | 388 | break; |
383 | } | 389 | } |
@@ -481,7 +487,7 @@ static int bnep_session(void *arg) | |||
481 | while (!atomic_read(&s->killed)) { | 487 | while (!atomic_read(&s->killed)) { |
482 | set_current_state(TASK_INTERRUPTIBLE); | 488 | set_current_state(TASK_INTERRUPTIBLE); |
483 | 489 | ||
484 | // RX | 490 | /* RX */ |
485 | while ((skb = skb_dequeue(&sk->sk_receive_queue))) { | 491 | while ((skb = skb_dequeue(&sk->sk_receive_queue))) { |
486 | skb_orphan(skb); | 492 | skb_orphan(skb); |
487 | bnep_rx_frame(s, skb); | 493 | bnep_rx_frame(s, skb); |
@@ -490,7 +496,7 @@ static int bnep_session(void *arg) | |||
490 | if (sk->sk_state != BT_CONNECTED) | 496 | if (sk->sk_state != BT_CONNECTED) |
491 | break; | 497 | break; |
492 | 498 | ||
493 | // TX | 499 | /* TX */ |
494 | while ((skb = skb_dequeue(&sk->sk_write_queue))) | 500 | while ((skb = skb_dequeue(&sk->sk_write_queue))) |
495 | if (bnep_tx_frame(s, skb)) | 501 | if (bnep_tx_frame(s, skb)) |
496 | break; | 502 | break; |
@@ -558,8 +564,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) | |||
558 | 564 | ||
559 | /* session struct allocated as private part of net_device */ | 565 | /* session struct allocated as private part of net_device */ |
560 | dev = alloc_netdev(sizeof(struct bnep_session), | 566 | dev = alloc_netdev(sizeof(struct bnep_session), |
561 | (*req->device) ? req->device : "bnep%d", | 567 | (*req->device) ? req->device : "bnep%d", |
562 | bnep_net_setup); | 568 | bnep_net_setup); |
563 | if (!dev) | 569 | if (!dev) |
564 | return -ENOMEM; | 570 | return -ENOMEM; |
565 | 571 | ||
@@ -574,7 +580,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) | |||
574 | s = netdev_priv(dev); | 580 | s = netdev_priv(dev); |
575 | 581 | ||
576 | /* This is rx header therefore addresses are swapped. | 582 | /* This is rx header therefore addresses are swapped. |
577 | * ie eh.h_dest is our local address. */ | 583 | * ie. eh.h_dest is our local address. */ |
578 | memcpy(s->eh.h_dest, &src, ETH_ALEN); | 584 | memcpy(s->eh.h_dest, &src, ETH_ALEN); |
579 | memcpy(s->eh.h_source, &dst, ETH_ALEN); | 585 | memcpy(s->eh.h_source, &dst, ETH_ALEN); |
580 | memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN); | 586 | memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN); |
@@ -600,9 +606,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) | |||
600 | SET_NETDEV_DEVTYPE(dev, &bnep_type); | 606 | SET_NETDEV_DEVTYPE(dev, &bnep_type); |
601 | 607 | ||
602 | err = register_netdev(dev); | 608 | err = register_netdev(dev); |
603 | if (err) { | 609 | if (err) |
604 | goto failed; | 610 | goto failed; |
605 | } | ||
606 | 611 | ||
607 | __bnep_link_session(s); | 612 | __bnep_link_session(s); |
608 | 613 | ||