diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2012-03-04 19:03:52 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-03-06 15:16:24 -0500 |
commit | 427a2eb1f568c9c5934a36105232c94553db9b69 (patch) | |
tree | addf7f00d1fe6e3c92db555e8f9f9cfcb7e7e718 /net | |
parent | 40c75f81d6852bb4fd08491074889187f77b8d1f (diff) |
NFC: LLCP code identation fixes
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/nfc/llcp/commands.c | 39 | ||||
-rw-r--r-- | net/nfc/llcp/llcp.c | 93 | ||||
-rw-r--r-- | net/nfc/llcp/llcp.h | 6 | ||||
-rw-r--r-- | net/nfc/llcp/sock.c | 55 |
4 files changed, 100 insertions, 93 deletions
diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index 7c74b82f2161..7b76eb7192f3 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c | |||
@@ -118,7 +118,7 @@ u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length) | |||
118 | } | 118 | } |
119 | 119 | ||
120 | int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, | 120 | int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, |
121 | u8 *tlv_array, u16 tlv_array_len) | 121 | u8 *tlv_array, u16 tlv_array_len) |
122 | { | 122 | { |
123 | u8 *tlv = tlv_array, type, length, offset = 0; | 123 | u8 *tlv = tlv_array, type, length, offset = 0; |
124 | 124 | ||
@@ -164,15 +164,15 @@ int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, | |||
164 | } | 164 | } |
165 | 165 | ||
166 | pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x rw %d\n", | 166 | pr_debug("version 0x%x miu %d lto %d opt 0x%x wks 0x%x rw %d\n", |
167 | local->remote_version, local->remote_miu, | 167 | local->remote_version, local->remote_miu, |
168 | local->remote_lto, local->remote_opt, | 168 | local->remote_lto, local->remote_opt, |
169 | local->remote_wks, local->remote_rw); | 169 | local->remote_wks, local->remote_rw); |
170 | 170 | ||
171 | return 0; | 171 | return 0; |
172 | } | 172 | } |
173 | 173 | ||
174 | static struct sk_buff *llcp_add_header(struct sk_buff *pdu, | 174 | static struct sk_buff *llcp_add_header(struct sk_buff *pdu, |
175 | u8 dsap, u8 ssap, u8 ptype) | 175 | u8 dsap, u8 ssap, u8 ptype) |
176 | { | 176 | { |
177 | u8 header[2]; | 177 | u8 header[2]; |
178 | 178 | ||
@@ -188,7 +188,8 @@ static struct sk_buff *llcp_add_header(struct sk_buff *pdu, | |||
188 | return pdu; | 188 | return pdu; |
189 | } | 189 | } |
190 | 190 | ||
191 | static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, u8 tlv_length) | 191 | static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, |
192 | u8 tlv_length) | ||
192 | { | 193 | { |
193 | /* XXX Add an skb length check */ | 194 | /* XXX Add an skb length check */ |
194 | 195 | ||
@@ -201,7 +202,7 @@ static struct sk_buff *llcp_add_tlv(struct sk_buff *pdu, u8 *tlv, u8 tlv_length) | |||
201 | } | 202 | } |
202 | 203 | ||
203 | static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock, | 204 | static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock, |
204 | u8 cmd, u16 size) | 205 | u8 cmd, u16 size) |
205 | { | 206 | { |
206 | struct sk_buff *skb; | 207 | struct sk_buff *skb; |
207 | int err; | 208 | int err; |
@@ -210,7 +211,7 @@ static struct sk_buff *llcp_allocate_pdu(struct nfc_llcp_sock *sock, | |||
210 | return NULL; | 211 | return NULL; |
211 | 212 | ||
212 | skb = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT, | 213 | skb = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT, |
213 | size + LLCP_HEADER_SIZE, &err); | 214 | size + LLCP_HEADER_SIZE, &err); |
214 | if (skb == NULL) { | 215 | if (skb == NULL) { |
215 | pr_err("Could not allocate PDU\n"); | 216 | pr_err("Could not allocate PDU\n"); |
216 | return NULL; | 217 | return NULL; |
@@ -278,7 +279,7 @@ int nfc_llcp_send_symm(struct nfc_dev *dev) | |||
278 | skb = llcp_add_header(skb, 0, 0, LLCP_PDU_SYMM); | 279 | skb = llcp_add_header(skb, 0, 0, LLCP_PDU_SYMM); |
279 | 280 | ||
280 | return nfc_data_exchange(dev, local->target_idx, skb, | 281 | return nfc_data_exchange(dev, local->target_idx, skb, |
281 | nfc_llcp_recv, local); | 282 | nfc_llcp_recv, local); |
282 | } | 283 | } |
283 | 284 | ||
284 | int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) | 285 | int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) |
@@ -300,14 +301,15 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) | |||
300 | 301 | ||
301 | if (sock->service_name != NULL) { | 302 | if (sock->service_name != NULL) { |
302 | service_name_tlv = nfc_llcp_build_tlv(LLCP_TLV_SN, | 303 | service_name_tlv = nfc_llcp_build_tlv(LLCP_TLV_SN, |
303 | sock->service_name, | 304 | sock->service_name, |
304 | sock->service_name_len, | 305 | sock->service_name_len, |
305 | &service_name_tlv_length); | 306 | &service_name_tlv_length); |
306 | size += service_name_tlv_length; | 307 | size += service_name_tlv_length; |
307 | } | 308 | } |
308 | 309 | ||
309 | miux = cpu_to_be16(LLCP_MAX_MIUX); | 310 | miux = cpu_to_be16(LLCP_MAX_MIUX); |
310 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length); | 311 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, |
312 | &miux_tlv_length); | ||
311 | size += miux_tlv_length; | 313 | size += miux_tlv_length; |
312 | 314 | ||
313 | rw = LLCP_MAX_RW; | 315 | rw = LLCP_MAX_RW; |
@@ -324,7 +326,7 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) | |||
324 | 326 | ||
325 | if (service_name_tlv != NULL) | 327 | if (service_name_tlv != NULL) |
326 | skb = llcp_add_tlv(skb, service_name_tlv, | 328 | skb = llcp_add_tlv(skb, service_name_tlv, |
327 | service_name_tlv_length); | 329 | service_name_tlv_length); |
328 | 330 | ||
329 | skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length); | 331 | skb = llcp_add_tlv(skb, miux_tlv, miux_tlv_length); |
330 | skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length); | 332 | skb = llcp_add_tlv(skb, rw_tlv, rw_tlv_length); |
@@ -360,7 +362,8 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) | |||
360 | return -ENODEV; | 362 | return -ENODEV; |
361 | 363 | ||
362 | miux = cpu_to_be16(LLCP_MAX_MIUX); | 364 | miux = cpu_to_be16(LLCP_MAX_MIUX); |
363 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, &miux_tlv_length); | 365 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, |
366 | &miux_tlv_length); | ||
364 | size += miux_tlv_length; | 367 | size += miux_tlv_length; |
365 | 368 | ||
366 | rw = LLCP_MAX_RW; | 369 | rw = LLCP_MAX_RW; |
@@ -443,7 +446,7 @@ int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock) | |||
443 | } | 446 | } |
444 | 447 | ||
445 | int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | 448 | int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, |
446 | struct msghdr *msg, size_t len) | 449 | struct msghdr *msg, size_t len) |
447 | { | 450 | { |
448 | struct sk_buff *pdu; | 451 | struct sk_buff *pdu; |
449 | struct sock *sk = &sock->sk; | 452 | struct sock *sk = &sock->sk; |
@@ -462,8 +465,8 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | |||
462 | return -ENOMEM; | 465 | return -ENOMEM; |
463 | 466 | ||
464 | if (memcpy_fromiovec(msg_data, msg->msg_iov, len)) { | 467 | if (memcpy_fromiovec(msg_data, msg->msg_iov, len)) { |
465 | kfree(msg_data); | 468 | kfree(msg_data); |
466 | return -EFAULT; | 469 | return -EFAULT; |
467 | } | 470 | } |
468 | 471 | ||
469 | remaining_len = len; | 472 | remaining_len = len; |
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 8af896dc759e..17a578f641f1 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c | |||
@@ -37,7 +37,6 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) | |||
37 | struct sock *sk, *parent_sk; | 37 | struct sock *sk, *parent_sk; |
38 | int i; | 38 | int i; |
39 | 39 | ||
40 | |||
41 | mutex_lock(&local->socket_lock); | 40 | mutex_lock(&local->socket_lock); |
42 | 41 | ||
43 | for (i = 0; i < LLCP_MAX_SAP; i++) { | 42 | for (i = 0; i < LLCP_MAX_SAP; i++) { |
@@ -73,7 +72,7 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local) | |||
73 | struct sock *accept_sk; | 72 | struct sock *accept_sk; |
74 | 73 | ||
75 | list_for_each_entry_safe(lsk, n, &parent->accept_queue, | 74 | list_for_each_entry_safe(lsk, n, &parent->accept_queue, |
76 | accept_queue) { | 75 | accept_queue) { |
77 | accept_sk = &lsk->sk; | 76 | accept_sk = &lsk->sk; |
78 | lock_sock(accept_sk); | 77 | lock_sock(accept_sk); |
79 | 78 | ||
@@ -118,7 +117,7 @@ static void nfc_llcp_clear_sdp(struct nfc_llcp_local *local) | |||
118 | static void nfc_llcp_timeout_work(struct work_struct *work) | 117 | static void nfc_llcp_timeout_work(struct work_struct *work) |
119 | { | 118 | { |
120 | struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, | 119 | struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, |
121 | timeout_work); | 120 | timeout_work); |
122 | 121 | ||
123 | nfc_dep_link_down(local->dev); | 122 | nfc_dep_link_down(local->dev); |
124 | } | 123 | } |
@@ -164,7 +163,7 @@ static int nfc_llcp_wks_sap(char *service_name, size_t service_name_len) | |||
164 | 163 | ||
165 | num_wks = ARRAY_SIZE(wks); | 164 | num_wks = ARRAY_SIZE(wks); |
166 | 165 | ||
167 | for (sap = 0 ; sap < num_wks; sap++) { | 166 | for (sap = 0; sap < num_wks; sap++) { |
168 | if (wks[sap] == NULL) | 167 | if (wks[sap] == NULL) |
169 | continue; | 168 | continue; |
170 | 169 | ||
@@ -176,13 +175,13 @@ static int nfc_llcp_wks_sap(char *service_name, size_t service_name_len) | |||
176 | } | 175 | } |
177 | 176 | ||
178 | u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, | 177 | u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, |
179 | struct nfc_llcp_sock *sock) | 178 | struct nfc_llcp_sock *sock) |
180 | { | 179 | { |
181 | mutex_lock(&local->sdp_lock); | 180 | mutex_lock(&local->sdp_lock); |
182 | 181 | ||
183 | if (sock->service_name != NULL && sock->service_name_len > 0) { | 182 | if (sock->service_name != NULL && sock->service_name_len > 0) { |
184 | int ssap = nfc_llcp_wks_sap(sock->service_name, | 183 | int ssap = nfc_llcp_wks_sap(sock->service_name, |
185 | sock->service_name_len); | 184 | sock->service_name_len); |
186 | 185 | ||
187 | if (ssap > 0) { | 186 | if (ssap > 0) { |
188 | pr_debug("WKS %d\n", ssap); | 187 | pr_debug("WKS %d\n", ssap); |
@@ -312,7 +311,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local) | |||
312 | 311 | ||
313 | version = LLCP_VERSION_11; | 312 | version = LLCP_VERSION_11; |
314 | version_tlv = nfc_llcp_build_tlv(LLCP_TLV_VERSION, &version, | 313 | version_tlv = nfc_llcp_build_tlv(LLCP_TLV_VERSION, &version, |
315 | 1, &version_length); | 314 | 1, &version_length); |
316 | gb_len += version_length; | 315 | gb_len += version_length; |
317 | 316 | ||
318 | /* 1500 ms */ | 317 | /* 1500 ms */ |
@@ -322,7 +321,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local) | |||
322 | 321 | ||
323 | pr_debug("Local wks 0x%lx\n", local->local_wks); | 322 | pr_debug("Local wks 0x%lx\n", local->local_wks); |
324 | wks_tlv = nfc_llcp_build_tlv(LLCP_TLV_WKS, (u8 *)&local->local_wks, 2, | 323 | wks_tlv = nfc_llcp_build_tlv(LLCP_TLV_WKS, (u8 *)&local->local_wks, 2, |
325 | &wks_length); | 324 | &wks_length); |
326 | gb_len += wks_length; | 325 | gb_len += wks_length; |
327 | 326 | ||
328 | gb_len += ARRAY_SIZE(llcp_magic); | 327 | gb_len += ARRAY_SIZE(llcp_magic); |
@@ -367,8 +366,7 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) | |||
367 | memcpy(local->remote_gb, gb, gb_len); | 366 | memcpy(local->remote_gb, gb, gb_len); |
368 | local->remote_gb_len = gb_len; | 367 | local->remote_gb_len = gb_len; |
369 | 368 | ||
370 | if (local->remote_gb == NULL || | 369 | if (local->remote_gb == NULL || local->remote_gb_len == 0) |
371 | local->remote_gb_len == 0) | ||
372 | return -ENODEV; | 370 | return -ENODEV; |
373 | 371 | ||
374 | if (memcmp(local->remote_gb, llcp_magic, 3)) { | 372 | if (memcmp(local->remote_gb, llcp_magic, 3)) { |
@@ -377,26 +375,27 @@ int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len) | |||
377 | } | 375 | } |
378 | 376 | ||
379 | return nfc_llcp_parse_tlv(local, | 377 | return nfc_llcp_parse_tlv(local, |
380 | &local->remote_gb[3], local->remote_gb_len - 3); | 378 | &local->remote_gb[3], |
379 | local->remote_gb_len - 3); | ||
381 | } | 380 | } |
382 | 381 | ||
383 | static void nfc_llcp_tx_work(struct work_struct *work) | 382 | static void nfc_llcp_tx_work(struct work_struct *work) |
384 | { | 383 | { |
385 | struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, | 384 | struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, |
386 | tx_work); | 385 | tx_work); |
387 | struct sk_buff *skb; | 386 | struct sk_buff *skb; |
388 | 387 | ||
389 | skb = skb_dequeue(&local->tx_queue); | 388 | skb = skb_dequeue(&local->tx_queue); |
390 | if (skb != NULL) { | 389 | if (skb != NULL) { |
391 | pr_debug("Sending pending skb\n"); | 390 | pr_debug("Sending pending skb\n"); |
392 | nfc_data_exchange(local->dev, local->target_idx, | 391 | nfc_data_exchange(local->dev, local->target_idx, |
393 | skb, nfc_llcp_recv, local); | 392 | skb, nfc_llcp_recv, local); |
394 | } else { | 393 | } else { |
395 | nfc_llcp_send_symm(local->dev); | 394 | nfc_llcp_send_symm(local->dev); |
396 | } | 395 | } |
397 | 396 | ||
398 | mod_timer(&local->link_timer, | 397 | mod_timer(&local->link_timer, |
399 | jiffies + msecs_to_jiffies(local->remote_lto)); | 398 | jiffies + msecs_to_jiffies(local->remote_lto)); |
400 | } | 399 | } |
401 | 400 | ||
402 | static u8 nfc_llcp_dsap(struct sk_buff *pdu) | 401 | static u8 nfc_llcp_dsap(struct sk_buff *pdu) |
@@ -432,7 +431,7 @@ static void nfc_llcp_set_nrns(struct nfc_llcp_sock *sock, struct sk_buff *pdu) | |||
432 | } | 431 | } |
433 | 432 | ||
434 | static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, | 433 | static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, |
435 | u8 ssap, u8 dsap) | 434 | u8 ssap, u8 dsap) |
436 | { | 435 | { |
437 | struct nfc_llcp_sock *sock, *llcp_sock, *n; | 436 | struct nfc_llcp_sock *sock, *llcp_sock, *n; |
438 | 437 | ||
@@ -456,7 +455,7 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, | |||
456 | 455 | ||
457 | list_for_each_entry_safe(llcp_sock, n, &sock->list, list) { | 456 | list_for_each_entry_safe(llcp_sock, n, &sock->list, list) { |
458 | pr_debug("llcp_sock %p sk %p dsap %d\n", llcp_sock, | 457 | pr_debug("llcp_sock %p sk %p dsap %d\n", llcp_sock, |
459 | &llcp_sock->sk, llcp_sock->dsap); | 458 | &llcp_sock->sk, llcp_sock->dsap); |
460 | if (llcp_sock->dsap == dsap) { | 459 | if (llcp_sock->dsap == dsap) { |
461 | sock_hold(&llcp_sock->sk); | 460 | sock_hold(&llcp_sock->sk); |
462 | mutex_unlock(&local->socket_lock); | 461 | mutex_unlock(&local->socket_lock); |
@@ -500,7 +499,7 @@ static u8 *nfc_llcp_connect_sn(struct sk_buff *skb, size_t *sn_len) | |||
500 | } | 499 | } |
501 | 500 | ||
502 | static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, | 501 | static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, |
503 | struct sk_buff *skb) | 502 | struct sk_buff *skb) |
504 | { | 503 | { |
505 | struct sock *new_sk, *parent; | 504 | struct sock *new_sk, *parent; |
506 | struct nfc_llcp_sock *sock, *new_sock; | 505 | struct nfc_llcp_sock *sock, *new_sock; |
@@ -512,7 +511,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, | |||
512 | pr_debug("%d %d\n", dsap, ssap); | 511 | pr_debug("%d %d\n", dsap, ssap); |
513 | 512 | ||
514 | nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], | 513 | nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], |
515 | skb->len - LLCP_HEADER_SIZE); | 514 | skb->len - LLCP_HEADER_SIZE); |
516 | 515 | ||
517 | if (dsap != LLCP_SAP_SDP) { | 516 | if (dsap != LLCP_SAP_SDP) { |
518 | bound_sap = dsap; | 517 | bound_sap = dsap; |
@@ -531,7 +530,7 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, | |||
531 | lock_sock(&sock->sk); | 530 | lock_sock(&sock->sk); |
532 | 531 | ||
533 | if (sock->dsap == LLCP_SAP_SDP && | 532 | if (sock->dsap == LLCP_SAP_SDP && |
534 | sock->sk.sk_state == LLCP_LISTEN) | 533 | sock->sk.sk_state == LLCP_LISTEN) |
535 | goto enqueue; | 534 | goto enqueue; |
536 | } else { | 535 | } else { |
537 | u8 *sn; | 536 | u8 *sn; |
@@ -547,23 +546,23 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, | |||
547 | 546 | ||
548 | mutex_lock(&local->socket_lock); | 547 | mutex_lock(&local->socket_lock); |
549 | for (bound_sap = 0; bound_sap < LLCP_LOCAL_SAP_OFFSET; | 548 | for (bound_sap = 0; bound_sap < LLCP_LOCAL_SAP_OFFSET; |
550 | bound_sap++) { | 549 | bound_sap++) { |
551 | sock = local->sockets[bound_sap]; | 550 | sock = local->sockets[bound_sap]; |
552 | if (sock == NULL) | 551 | if (sock == NULL) |
553 | continue; | 552 | continue; |
554 | 553 | ||
555 | if (sock->service_name == NULL || | 554 | if (sock->service_name == NULL || |
556 | sock->service_name_len == 0) | 555 | sock->service_name_len == 0) |
557 | continue; | 556 | continue; |
558 | 557 | ||
559 | if (sock->service_name_len != sn_len) | 558 | if (sock->service_name_len != sn_len) |
560 | continue; | 559 | continue; |
561 | 560 | ||
562 | if (sock->dsap == LLCP_SAP_SDP && | 561 | if (sock->dsap == LLCP_SAP_SDP && |
563 | sock->sk.sk_state == LLCP_LISTEN && | 562 | sock->sk.sk_state == LLCP_LISTEN && |
564 | !memcmp(sn, sock->service_name, sn_len)) { | 563 | !memcmp(sn, sock->service_name, sn_len)) { |
565 | pr_debug("Found service name at SAP %d\n", | 564 | pr_debug("Found service name at SAP %d\n", |
566 | bound_sap); | 565 | bound_sap); |
567 | sock_hold(&sock->sk); | 566 | sock_hold(&sock->sk); |
568 | mutex_unlock(&local->socket_lock); | 567 | mutex_unlock(&local->socket_lock); |
569 | 568 | ||
@@ -588,8 +587,7 @@ enqueue: | |||
588 | goto fail; | 587 | goto fail; |
589 | } | 588 | } |
590 | 589 | ||
591 | new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type, | 590 | new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type, GFP_ATOMIC); |
592 | GFP_ATOMIC); | ||
593 | if (new_sk == NULL) { | 591 | if (new_sk == NULL) { |
594 | reason = LLCP_DM_REJ; | 592 | reason = LLCP_DM_REJ; |
595 | release_sock(&sock->sk); | 593 | release_sock(&sock->sk); |
@@ -640,12 +638,12 @@ int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) | |||
640 | struct nfc_llcp_local *local = sock->local; | 638 | struct nfc_llcp_local *local = sock->local; |
641 | 639 | ||
642 | pr_debug("Remote ready %d tx queue len %d remote rw %d", | 640 | pr_debug("Remote ready %d tx queue len %d remote rw %d", |
643 | sock->remote_ready, skb_queue_len(&sock->tx_pending_queue), | 641 | sock->remote_ready, skb_queue_len(&sock->tx_pending_queue), |
644 | local->remote_rw); | 642 | local->remote_rw); |
645 | 643 | ||
646 | /* Try to queue some I frames for transmission */ | 644 | /* Try to queue some I frames for transmission */ |
647 | while (sock->remote_ready && | 645 | while (sock->remote_ready && |
648 | skb_queue_len(&sock->tx_pending_queue) < local->remote_rw) { | 646 | skb_queue_len(&sock->tx_pending_queue) < local->remote_rw) { |
649 | struct sk_buff *pdu, *pending_pdu; | 647 | struct sk_buff *pdu, *pending_pdu; |
650 | 648 | ||
651 | pdu = skb_dequeue(&sock->tx_queue); | 649 | pdu = skb_dequeue(&sock->tx_queue); |
@@ -666,7 +664,7 @@ int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) | |||
666 | } | 664 | } |
667 | 665 | ||
668 | static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, | 666 | static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, |
669 | struct sk_buff *skb) | 667 | struct sk_buff *skb) |
670 | { | 668 | { |
671 | struct nfc_llcp_sock *llcp_sock; | 669 | struct nfc_llcp_sock *llcp_sock; |
672 | struct sock *sk; | 670 | struct sock *sk; |
@@ -724,7 +722,7 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, | |||
724 | 722 | ||
725 | if (ptype == LLCP_PDU_RR) | 723 | if (ptype == LLCP_PDU_RR) |
726 | llcp_sock->remote_ready = true; | 724 | llcp_sock->remote_ready = true; |
727 | else if (ptype == LLCP_PDU_RNR) | 725 | else if (ptype == LLCP_PDU_RNR) |
728 | llcp_sock->remote_ready = false; | 726 | llcp_sock->remote_ready = false; |
729 | 727 | ||
730 | if (nfc_llcp_queue_i_frames(llcp_sock) == 0) | 728 | if (nfc_llcp_queue_i_frames(llcp_sock) == 0) |
@@ -735,7 +733,7 @@ static void nfc_llcp_recv_hdlc(struct nfc_llcp_local *local, | |||
735 | } | 733 | } |
736 | 734 | ||
737 | static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, | 735 | static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, |
738 | struct sk_buff *skb) | 736 | struct sk_buff *skb) |
739 | { | 737 | { |
740 | struct nfc_llcp_sock *llcp_sock; | 738 | struct nfc_llcp_sock *llcp_sock; |
741 | struct sock *sk; | 739 | struct sock *sk; |
@@ -757,7 +755,6 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, | |||
757 | nfc_llcp_sock_put(llcp_sock); | 755 | nfc_llcp_sock_put(llcp_sock); |
758 | } | 756 | } |
759 | 757 | ||
760 | |||
761 | if (sk->sk_state == LLCP_CONNECTED) { | 758 | if (sk->sk_state == LLCP_CONNECTED) { |
762 | nfc_put_device(local->dev); | 759 | nfc_put_device(local->dev); |
763 | sk->sk_state = LLCP_CLOSED; | 760 | sk->sk_state = LLCP_CLOSED; |
@@ -770,13 +767,11 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, | |||
770 | nfc_llcp_sock_put(llcp_sock); | 767 | nfc_llcp_sock_put(llcp_sock); |
771 | } | 768 | } |
772 | 769 | ||
773 | static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, | 770 | static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb) |
774 | struct sk_buff *skb) | ||
775 | { | 771 | { |
776 | struct nfc_llcp_sock *llcp_sock; | 772 | struct nfc_llcp_sock *llcp_sock; |
777 | u8 dsap, ssap; | 773 | u8 dsap, ssap; |
778 | 774 | ||
779 | |||
780 | dsap = nfc_llcp_dsap(skb); | 775 | dsap = nfc_llcp_dsap(skb); |
781 | ssap = nfc_llcp_ssap(skb); | 776 | ssap = nfc_llcp_ssap(skb); |
782 | 777 | ||
@@ -795,7 +790,7 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, | |||
795 | llcp_sock->dsap = ssap; | 790 | llcp_sock->dsap = ssap; |
796 | 791 | ||
797 | nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], | 792 | nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], |
798 | skb->len - LLCP_HEADER_SIZE); | 793 | skb->len - LLCP_HEADER_SIZE); |
799 | 794 | ||
800 | nfc_llcp_sock_put(llcp_sock); | 795 | nfc_llcp_sock_put(llcp_sock); |
801 | } | 796 | } |
@@ -803,7 +798,7 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, | |||
803 | static void nfc_llcp_rx_work(struct work_struct *work) | 798 | static void nfc_llcp_rx_work(struct work_struct *work) |
804 | { | 799 | { |
805 | struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, | 800 | struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, |
806 | rx_work); | 801 | rx_work); |
807 | u8 dsap, ssap, ptype; | 802 | u8 dsap, ssap, ptype; |
808 | struct sk_buff *skb; | 803 | struct sk_buff *skb; |
809 | 804 | ||
@@ -861,7 +856,7 @@ void nfc_llcp_recv(void *data, struct sk_buff *skb, int err) | |||
861 | 856 | ||
862 | pr_debug("Received an LLCP PDU\n"); | 857 | pr_debug("Received an LLCP PDU\n"); |
863 | if (err < 0) { | 858 | if (err < 0) { |
864 | pr_err("err %d", err); | 859 | pr_err("err %d\n", err); |
865 | return; | 860 | return; |
866 | } | 861 | } |
867 | 862 | ||
@@ -907,7 +902,7 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, | |||
907 | queue_work(local->tx_wq, &local->tx_work); | 902 | queue_work(local->tx_wq, &local->tx_work); |
908 | } else { | 903 | } else { |
909 | mod_timer(&local->link_timer, | 904 | mod_timer(&local->link_timer, |
910 | jiffies + msecs_to_jiffies(local->remote_lto)); | 905 | jiffies + msecs_to_jiffies(local->remote_lto)); |
911 | } | 906 | } |
912 | } | 907 | } |
913 | 908 | ||
@@ -933,8 +928,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) | |||
933 | skb_queue_head_init(&local->tx_queue); | 928 | skb_queue_head_init(&local->tx_queue); |
934 | INIT_WORK(&local->tx_work, nfc_llcp_tx_work); | 929 | INIT_WORK(&local->tx_work, nfc_llcp_tx_work); |
935 | snprintf(name, sizeof(name), "%s_llcp_tx_wq", dev_name(dev)); | 930 | snprintf(name, sizeof(name), "%s_llcp_tx_wq", dev_name(dev)); |
936 | local->tx_wq = alloc_workqueue(name, | 931 | local->tx_wq = |
937 | WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1); | 932 | alloc_workqueue(name, |
933 | WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, | ||
934 | 1); | ||
938 | if (local->tx_wq == NULL) { | 935 | if (local->tx_wq == NULL) { |
939 | err = -ENOMEM; | 936 | err = -ENOMEM; |
940 | goto err_local; | 937 | goto err_local; |
@@ -943,8 +940,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) | |||
943 | local->rx_pending = NULL; | 940 | local->rx_pending = NULL; |
944 | INIT_WORK(&local->rx_work, nfc_llcp_rx_work); | 941 | INIT_WORK(&local->rx_work, nfc_llcp_rx_work); |
945 | snprintf(name, sizeof(name), "%s_llcp_rx_wq", dev_name(dev)); | 942 | snprintf(name, sizeof(name), "%s_llcp_rx_wq", dev_name(dev)); |
946 | local->rx_wq = alloc_workqueue(name, | 943 | local->rx_wq = |
947 | WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1); | 944 | alloc_workqueue(name, |
945 | WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, | ||
946 | 1); | ||
948 | if (local->rx_wq == NULL) { | 947 | if (local->rx_wq == NULL) { |
949 | err = -ENOMEM; | 948 | err = -ENOMEM; |
950 | goto err_tx_wq; | 949 | goto err_tx_wq; |
@@ -952,8 +951,10 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) | |||
952 | 951 | ||
953 | INIT_WORK(&local->timeout_work, nfc_llcp_timeout_work); | 952 | INIT_WORK(&local->timeout_work, nfc_llcp_timeout_work); |
954 | snprintf(name, sizeof(name), "%s_llcp_timeout_wq", dev_name(dev)); | 953 | snprintf(name, sizeof(name), "%s_llcp_timeout_wq", dev_name(dev)); |
955 | local->timeout_wq = alloc_workqueue(name, | 954 | local->timeout_wq = |
956 | WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, 1); | 955 | alloc_workqueue(name, |
956 | WQ_NON_REENTRANT | WQ_UNBOUND | WQ_MEM_RECLAIM, | ||
957 | 1); | ||
957 | if (local->timeout_wq == NULL) { | 958 | if (local->timeout_wq == NULL) { |
958 | err = -ENOMEM; | 959 | err = -ENOMEM; |
959 | goto err_rx_wq; | 960 | goto err_rx_wq; |
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h index 70e1762d6e8d..50680ce5ae43 100644 --- a/net/nfc/llcp/llcp.h +++ b/net/nfc/llcp/llcp.h | |||
@@ -166,7 +166,7 @@ struct nfc_llcp_sock { | |||
166 | 166 | ||
167 | struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); | 167 | struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); |
168 | u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, | 168 | u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, |
169 | struct nfc_llcp_sock *sock); | 169 | struct nfc_llcp_sock *sock); |
170 | u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local); | 170 | u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local); |
171 | void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap); | 171 | void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap); |
172 | int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock); | 172 | int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock); |
@@ -180,7 +180,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock); | |||
180 | 180 | ||
181 | /* TLV API */ | 181 | /* TLV API */ |
182 | int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, | 182 | int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, |
183 | u8 *tlv_array, u16 tlv_array_len); | 183 | u8 *tlv_array, u16 tlv_array_len); |
184 | 184 | ||
185 | /* Commands API */ | 185 | /* Commands API */ |
186 | void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); | 186 | void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); |
@@ -193,7 +193,7 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock); | |||
193 | int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason); | 193 | int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason); |
194 | int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock); | 194 | int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock); |
195 | int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | 195 | int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, |
196 | struct msghdr *msg, size_t len); | 196 | struct msghdr *msg, size_t len); |
197 | int nfc_llcp_send_rr(struct nfc_llcp_sock *sock); | 197 | int nfc_llcp_send_rr(struct nfc_llcp_sock *sock); |
198 | 198 | ||
199 | /* Socket API */ | 199 | /* Socket API */ |
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index 35825e20163a..c13e02ebdef9 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c | |||
@@ -78,9 +78,11 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) | |||
78 | llcp_sock->local = local; | 78 | llcp_sock->local = local; |
79 | llcp_sock->nfc_protocol = llcp_addr.nfc_protocol; | 79 | llcp_sock->nfc_protocol = llcp_addr.nfc_protocol; |
80 | llcp_sock->service_name_len = min_t(unsigned int, | 80 | llcp_sock->service_name_len = min_t(unsigned int, |
81 | llcp_addr.service_name_len, NFC_LLCP_MAX_SERVICE_NAME); | 81 | llcp_addr.service_name_len, |
82 | NFC_LLCP_MAX_SERVICE_NAME); | ||
82 | llcp_sock->service_name = kmemdup(llcp_addr.service_name, | 83 | llcp_sock->service_name = kmemdup(llcp_addr.service_name, |
83 | llcp_sock->service_name_len, GFP_KERNEL); | 84 | llcp_sock->service_name_len, |
85 | GFP_KERNEL); | ||
84 | 86 | ||
85 | llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock); | 87 | llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock); |
86 | if (llcp_sock->ssap == LLCP_MAX_SAP) | 88 | if (llcp_sock->ssap == LLCP_MAX_SAP) |
@@ -110,7 +112,7 @@ static int llcp_sock_listen(struct socket *sock, int backlog) | |||
110 | lock_sock(sk); | 112 | lock_sock(sk); |
111 | 113 | ||
112 | if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM) | 114 | if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM) |
113 | || sk->sk_state != LLCP_BOUND) { | 115 | || sk->sk_state != LLCP_BOUND) { |
114 | ret = -EBADFD; | 116 | ret = -EBADFD; |
115 | goto error; | 117 | goto error; |
116 | } | 118 | } |
@@ -149,13 +151,13 @@ void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk) | |||
149 | sock_hold(sk); | 151 | sock_hold(sk); |
150 | 152 | ||
151 | list_add_tail(&llcp_sock->accept_queue, | 153 | list_add_tail(&llcp_sock->accept_queue, |
152 | &llcp_sock_parent->accept_queue); | 154 | &llcp_sock_parent->accept_queue); |
153 | llcp_sock->parent = parent; | 155 | llcp_sock->parent = parent; |
154 | sk_acceptq_added(parent); | 156 | sk_acceptq_added(parent); |
155 | } | 157 | } |
156 | 158 | ||
157 | struct sock *nfc_llcp_accept_dequeue(struct sock *parent, | 159 | struct sock *nfc_llcp_accept_dequeue(struct sock *parent, |
158 | struct socket *newsock) | 160 | struct socket *newsock) |
159 | { | 161 | { |
160 | struct nfc_llcp_sock *lsk, *n, *llcp_parent; | 162 | struct nfc_llcp_sock *lsk, *n, *llcp_parent; |
161 | struct sock *sk; | 163 | struct sock *sk; |
@@ -163,7 +165,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent, | |||
163 | llcp_parent = nfc_llcp_sock(parent); | 165 | llcp_parent = nfc_llcp_sock(parent); |
164 | 166 | ||
165 | list_for_each_entry_safe(lsk, n, &llcp_parent->accept_queue, | 167 | list_for_each_entry_safe(lsk, n, &llcp_parent->accept_queue, |
166 | accept_queue) { | 168 | accept_queue) { |
167 | sk = &lsk->sk; | 169 | sk = &lsk->sk; |
168 | lock_sock(sk); | 170 | lock_sock(sk); |
169 | 171 | ||
@@ -192,7 +194,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent, | |||
192 | } | 194 | } |
193 | 195 | ||
194 | static int llcp_sock_accept(struct socket *sock, struct socket *newsock, | 196 | static int llcp_sock_accept(struct socket *sock, struct socket *newsock, |
195 | int flags) | 197 | int flags) |
196 | { | 198 | { |
197 | DECLARE_WAITQUEUE(wait, current); | 199 | DECLARE_WAITQUEUE(wait, current); |
198 | struct sock *sk = sock->sk, *new_sk; | 200 | struct sock *sk = sock->sk, *new_sk; |
@@ -248,7 +250,7 @@ error: | |||
248 | static int llcp_sock_getname(struct socket *sock, struct sockaddr *addr, | 250 | static int llcp_sock_getname(struct socket *sock, struct sockaddr *addr, |
249 | int *len, int peer) | 251 | int *len, int peer) |
250 | { | 252 | { |
251 | struct sockaddr_nfc_llcp *llcp_addr = (struct sockaddr_nfc_llcp *) addr; | 253 | struct sockaddr_nfc_llcp *llcp_addr = (struct sockaddr_nfc_llcp *)addr; |
252 | struct sock *sk = sock->sk; | 254 | struct sock *sk = sock->sk; |
253 | struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); | 255 | struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); |
254 | 256 | ||
@@ -262,7 +264,7 @@ static int llcp_sock_getname(struct socket *sock, struct sockaddr *addr, | |||
262 | llcp_addr->ssap = llcp_sock->ssap; | 264 | llcp_addr->ssap = llcp_sock->ssap; |
263 | llcp_addr->service_name_len = llcp_sock->service_name_len; | 265 | llcp_addr->service_name_len = llcp_sock->service_name_len; |
264 | memcpy(llcp_addr->service_name, llcp_sock->service_name, | 266 | memcpy(llcp_addr->service_name, llcp_sock->service_name, |
265 | llcp_addr->service_name_len); | 267 | llcp_addr->service_name_len); |
266 | 268 | ||
267 | return 0; | 269 | return 0; |
268 | } | 270 | } |
@@ -275,7 +277,7 @@ static inline unsigned int llcp_accept_poll(struct sock *parent) | |||
275 | parent_sock = nfc_llcp_sock(parent); | 277 | parent_sock = nfc_llcp_sock(parent); |
276 | 278 | ||
277 | list_for_each_entry_safe(llcp_sock, n, &parent_sock->accept_queue, | 279 | list_for_each_entry_safe(llcp_sock, n, &parent_sock->accept_queue, |
278 | accept_queue) { | 280 | accept_queue) { |
279 | sk = &llcp_sock->sk; | 281 | sk = &llcp_sock->sk; |
280 | 282 | ||
281 | if (sk->sk_state == LLCP_CONNECTED) | 283 | if (sk->sk_state == LLCP_CONNECTED) |
@@ -286,7 +288,7 @@ static inline unsigned int llcp_accept_poll(struct sock *parent) | |||
286 | } | 288 | } |
287 | 289 | ||
288 | static unsigned int llcp_sock_poll(struct file *file, struct socket *sock, | 290 | static unsigned int llcp_sock_poll(struct file *file, struct socket *sock, |
289 | poll_table *wait) | 291 | poll_table *wait) |
290 | { | 292 | { |
291 | struct sock *sk = sock->sk; | 293 | struct sock *sk = sock->sk; |
292 | unsigned int mask = 0; | 294 | unsigned int mask = 0; |
@@ -348,7 +350,7 @@ static int llcp_sock_release(struct socket *sock) | |||
348 | struct sock *accept_sk; | 350 | struct sock *accept_sk; |
349 | 351 | ||
350 | list_for_each_entry_safe(lsk, n, &llcp_sock->accept_queue, | 352 | list_for_each_entry_safe(lsk, n, &llcp_sock->accept_queue, |
351 | accept_queue) { | 353 | accept_queue) { |
352 | accept_sk = &lsk->sk; | 354 | accept_sk = &lsk->sk; |
353 | lock_sock(accept_sk); | 355 | lock_sock(accept_sk); |
354 | 356 | ||
@@ -363,9 +365,8 @@ static int llcp_sock_release(struct socket *sock) | |||
363 | 365 | ||
364 | /* Freeing the SAP */ | 366 | /* Freeing the SAP */ |
365 | if ((sk->sk_state == LLCP_CONNECTED | 367 | if ((sk->sk_state == LLCP_CONNECTED |
366 | && llcp_sock->ssap > LLCP_LOCAL_SAP_OFFSET) || | 368 | && llcp_sock->ssap > LLCP_LOCAL_SAP_OFFSET) || |
367 | sk->sk_state == LLCP_BOUND || | 369 | sk->sk_state == LLCP_BOUND || sk->sk_state == LLCP_LISTEN) |
368 | sk->sk_state == LLCP_LISTEN) | ||
369 | nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap); | 370 | nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap); |
370 | 371 | ||
371 | release_sock(sk); | 372 | release_sock(sk); |
@@ -378,7 +379,7 @@ out: | |||
378 | } | 379 | } |
379 | 380 | ||
380 | static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, | 381 | static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, |
381 | int len, int flags) | 382 | int len, int flags) |
382 | { | 383 | { |
383 | struct sock *sk = sock->sk; | 384 | struct sock *sk = sock->sk; |
384 | struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); | 385 | struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); |
@@ -390,7 +391,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, | |||
390 | pr_debug("sock %p sk %p flags 0x%x\n", sock, sk, flags); | 391 | pr_debug("sock %p sk %p flags 0x%x\n", sock, sk, flags); |
391 | 392 | ||
392 | if (!addr || len < sizeof(struct sockaddr_nfc) || | 393 | if (!addr || len < sizeof(struct sockaddr_nfc) || |
393 | addr->sa_family != AF_NFC) { | 394 | addr->sa_family != AF_NFC) { |
394 | pr_err("Invalid socket\n"); | 395 | pr_err("Invalid socket\n"); |
395 | return -EINVAL; | 396 | return -EINVAL; |
396 | } | 397 | } |
@@ -401,7 +402,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, | |||
401 | } | 402 | } |
402 | 403 | ||
403 | pr_debug("addr dev_idx=%u target_idx=%u protocol=%u\n", addr->dev_idx, | 404 | pr_debug("addr dev_idx=%u target_idx=%u protocol=%u\n", addr->dev_idx, |
404 | addr->target_idx, addr->nfc_protocol); | 405 | addr->target_idx, addr->nfc_protocol); |
405 | 406 | ||
406 | lock_sock(sk); | 407 | lock_sock(sk); |
407 | 408 | ||
@@ -431,7 +432,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, | |||
431 | device_unlock(&dev->dev); | 432 | device_unlock(&dev->dev); |
432 | 433 | ||
433 | if (local->rf_mode == NFC_RF_INITIATOR && | 434 | if (local->rf_mode == NFC_RF_INITIATOR && |
434 | addr->target_idx != local->target_idx) { | 435 | addr->target_idx != local->target_idx) { |
435 | ret = -ENOLINK; | 436 | ret = -ENOLINK; |
436 | goto put_dev; | 437 | goto put_dev; |
437 | } | 438 | } |
@@ -449,9 +450,11 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, | |||
449 | llcp_sock->dsap = LLCP_SAP_SDP; | 450 | llcp_sock->dsap = LLCP_SAP_SDP; |
450 | llcp_sock->nfc_protocol = addr->nfc_protocol; | 451 | llcp_sock->nfc_protocol = addr->nfc_protocol; |
451 | llcp_sock->service_name_len = min_t(unsigned int, | 452 | llcp_sock->service_name_len = min_t(unsigned int, |
452 | addr->service_name_len, NFC_LLCP_MAX_SERVICE_NAME); | 453 | addr->service_name_len, |
454 | NFC_LLCP_MAX_SERVICE_NAME); | ||
453 | llcp_sock->service_name = kmemdup(addr->service_name, | 455 | llcp_sock->service_name = kmemdup(addr->service_name, |
454 | llcp_sock->service_name_len, GFP_KERNEL); | 456 | llcp_sock->service_name_len, |
457 | GFP_KERNEL); | ||
455 | 458 | ||
456 | local->sockets[llcp_sock->ssap] = llcp_sock; | 459 | local->sockets[llcp_sock->ssap] = llcp_sock; |
457 | 460 | ||
@@ -473,7 +476,7 @@ error: | |||
473 | } | 476 | } |
474 | 477 | ||
475 | static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | 478 | static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock, |
476 | struct msghdr *msg, size_t len) | 479 | struct msghdr *msg, size_t len) |
477 | { | 480 | { |
478 | struct sock *sk = sock->sk; | 481 | struct sock *sk = sock->sk; |
479 | struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); | 482 | struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); |
@@ -514,7 +517,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
514 | lock_sock(sk); | 517 | lock_sock(sk); |
515 | 518 | ||
516 | if (sk->sk_state == LLCP_CLOSED && | 519 | if (sk->sk_state == LLCP_CLOSED && |
517 | skb_queue_empty(&sk->sk_receive_queue)) { | 520 | skb_queue_empty(&sk->sk_receive_queue)) { |
518 | release_sock(sk); | 521 | release_sock(sk); |
519 | return 0; | 522 | return 0; |
520 | } | 523 | } |
@@ -527,7 +530,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
527 | skb = skb_recv_datagram(sk, flags, noblock, &err); | 530 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
528 | if (!skb) { | 531 | if (!skb) { |
529 | pr_err("Recv datagram failed state %d %d %d", | 532 | pr_err("Recv datagram failed state %d %d %d", |
530 | sk->sk_state, err, sock_error(sk)); | 533 | sk->sk_state, err, sock_error(sk)); |
531 | 534 | ||
532 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 535 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
533 | return 0; | 536 | return 0; |
@@ -535,7 +538,7 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
535 | return err; | 538 | return err; |
536 | } | 539 | } |
537 | 540 | ||
538 | rlen = skb->len; /* real length of skb */ | 541 | rlen = skb->len; /* real length of skb */ |
539 | copied = min_t(unsigned int, rlen, len); | 542 | copied = min_t(unsigned int, rlen, len); |
540 | 543 | ||
541 | cskb = skb; | 544 | cskb = skb; |
@@ -664,7 +667,7 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock) | |||
664 | } | 667 | } |
665 | 668 | ||
666 | static int llcp_sock_create(struct net *net, struct socket *sock, | 669 | static int llcp_sock_create(struct net *net, struct socket *sock, |
667 | const struct nfc_protocol *nfc_proto) | 670 | const struct nfc_protocol *nfc_proto) |
668 | { | 671 | { |
669 | struct sock *sk; | 672 | struct sock *sk; |
670 | 673 | ||