diff options
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/core.c | 112 | ||||
-rw-r--r-- | net/nfc/hci/Kconfig | 1 | ||||
-rw-r--r-- | net/nfc/hci/core.c | 78 | ||||
-rw-r--r-- | net/nfc/hci/shdlc.c | 12 | ||||
-rw-r--r-- | net/nfc/llcp/commands.c | 4 | ||||
-rw-r--r-- | net/nfc/llcp/llcp.c | 7 | ||||
-rw-r--r-- | net/nfc/llcp/sock.c | 57 | ||||
-rw-r--r-- | net/nfc/nci/core.c | 27 | ||||
-rw-r--r-- | net/nfc/nci/data.c | 8 | ||||
-rw-r--r-- | net/nfc/nci/lib.c | 1 | ||||
-rw-r--r-- | net/nfc/nci/ntf.c | 2 | ||||
-rw-r--r-- | net/nfc/netlink.c | 6 | ||||
-rw-r--r-- | net/nfc/nfc.h | 2 |
13 files changed, 209 insertions, 108 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c index 3192c3f589ee..9f6ce011d35d 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c | |||
@@ -97,7 +97,7 @@ int nfc_dev_down(struct nfc_dev *dev) | |||
97 | goto error; | 97 | goto error; |
98 | } | 98 | } |
99 | 99 | ||
100 | if (dev->polling || dev->activated_target_idx != NFC_TARGET_IDX_NONE) { | 100 | if (dev->polling || dev->active_target) { |
101 | rc = -EBUSY; | 101 | rc = -EBUSY; |
102 | goto error; | 102 | goto error; |
103 | } | 103 | } |
@@ -183,11 +183,27 @@ error: | |||
183 | return rc; | 183 | return rc; |
184 | } | 184 | } |
185 | 185 | ||
186 | static struct nfc_target *nfc_find_target(struct nfc_dev *dev, u32 target_idx) | ||
187 | { | ||
188 | int i; | ||
189 | |||
190 | if (dev->n_targets == 0) | ||
191 | return NULL; | ||
192 | |||
193 | for (i = 0; i < dev->n_targets ; i++) { | ||
194 | if (dev->targets[i].idx == target_idx) | ||
195 | return &dev->targets[i]; | ||
196 | } | ||
197 | |||
198 | return NULL; | ||
199 | } | ||
200 | |||
186 | int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode) | 201 | int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode) |
187 | { | 202 | { |
188 | int rc = 0; | 203 | int rc = 0; |
189 | u8 *gb; | 204 | u8 *gb; |
190 | size_t gb_len; | 205 | size_t gb_len; |
206 | struct nfc_target *target; | ||
191 | 207 | ||
192 | pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode); | 208 | pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode); |
193 | 209 | ||
@@ -212,9 +228,15 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode) | |||
212 | goto error; | 228 | goto error; |
213 | } | 229 | } |
214 | 230 | ||
215 | rc = dev->ops->dep_link_up(dev, target_index, comm_mode, gb, gb_len); | 231 | target = nfc_find_target(dev, target_index); |
232 | if (target == NULL) { | ||
233 | rc = -ENOTCONN; | ||
234 | goto error; | ||
235 | } | ||
236 | |||
237 | rc = dev->ops->dep_link_up(dev, target, comm_mode, gb, gb_len); | ||
216 | if (!rc) | 238 | if (!rc) |
217 | dev->activated_target_idx = target_index; | 239 | dev->active_target = target; |
218 | 240 | ||
219 | error: | 241 | error: |
220 | device_unlock(&dev->dev); | 242 | device_unlock(&dev->dev); |
@@ -250,7 +272,7 @@ int nfc_dep_link_down(struct nfc_dev *dev) | |||
250 | rc = dev->ops->dep_link_down(dev); | 272 | rc = dev->ops->dep_link_down(dev); |
251 | if (!rc) { | 273 | if (!rc) { |
252 | dev->dep_link_up = false; | 274 | dev->dep_link_up = false; |
253 | dev->activated_target_idx = NFC_TARGET_IDX_NONE; | 275 | dev->active_target = NULL; |
254 | nfc_llcp_mac_is_down(dev); | 276 | nfc_llcp_mac_is_down(dev); |
255 | nfc_genl_dep_link_down_event(dev); | 277 | nfc_genl_dep_link_down_event(dev); |
256 | } | 278 | } |
@@ -282,6 +304,7 @@ EXPORT_SYMBOL(nfc_dep_link_is_up); | |||
282 | int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol) | 304 | int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol) |
283 | { | 305 | { |
284 | int rc; | 306 | int rc; |
307 | struct nfc_target *target; | ||
285 | 308 | ||
286 | pr_debug("dev_name=%s target_idx=%u protocol=%u\n", | 309 | pr_debug("dev_name=%s target_idx=%u protocol=%u\n", |
287 | dev_name(&dev->dev), target_idx, protocol); | 310 | dev_name(&dev->dev), target_idx, protocol); |
@@ -293,9 +316,20 @@ int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol) | |||
293 | goto error; | 316 | goto error; |
294 | } | 317 | } |
295 | 318 | ||
296 | rc = dev->ops->activate_target(dev, target_idx, protocol); | 319 | if (dev->active_target) { |
320 | rc = -EBUSY; | ||
321 | goto error; | ||
322 | } | ||
323 | |||
324 | target = nfc_find_target(dev, target_idx); | ||
325 | if (target == NULL) { | ||
326 | rc = -ENOTCONN; | ||
327 | goto error; | ||
328 | } | ||
329 | |||
330 | rc = dev->ops->activate_target(dev, target, protocol); | ||
297 | if (!rc) { | 331 | if (!rc) { |
298 | dev->activated_target_idx = target_idx; | 332 | dev->active_target = target; |
299 | 333 | ||
300 | if (dev->ops->check_presence) | 334 | if (dev->ops->check_presence) |
301 | mod_timer(&dev->check_pres_timer, jiffies + | 335 | mod_timer(&dev->check_pres_timer, jiffies + |
@@ -327,11 +361,21 @@ int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx) | |||
327 | goto error; | 361 | goto error; |
328 | } | 362 | } |
329 | 363 | ||
364 | if (dev->active_target == NULL) { | ||
365 | rc = -ENOTCONN; | ||
366 | goto error; | ||
367 | } | ||
368 | |||
369 | if (dev->active_target->idx != target_idx) { | ||
370 | rc = -ENOTCONN; | ||
371 | goto error; | ||
372 | } | ||
373 | |||
330 | if (dev->ops->check_presence) | 374 | if (dev->ops->check_presence) |
331 | del_timer_sync(&dev->check_pres_timer); | 375 | del_timer_sync(&dev->check_pres_timer); |
332 | 376 | ||
333 | dev->ops->deactivate_target(dev, target_idx); | 377 | dev->ops->deactivate_target(dev, dev->active_target); |
334 | dev->activated_target_idx = NFC_TARGET_IDX_NONE; | 378 | dev->active_target = NULL; |
335 | 379 | ||
336 | error: | 380 | error: |
337 | device_unlock(&dev->dev); | 381 | device_unlock(&dev->dev); |
@@ -365,13 +409,13 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, | |||
365 | goto error; | 409 | goto error; |
366 | } | 410 | } |
367 | 411 | ||
368 | if (dev->activated_target_idx == NFC_TARGET_IDX_NONE) { | 412 | if (dev->active_target == NULL) { |
369 | rc = -ENOTCONN; | 413 | rc = -ENOTCONN; |
370 | kfree_skb(skb); | 414 | kfree_skb(skb); |
371 | goto error; | 415 | goto error; |
372 | } | 416 | } |
373 | 417 | ||
374 | if (target_idx != dev->activated_target_idx) { | 418 | if (dev->active_target->idx != target_idx) { |
375 | rc = -EADDRNOTAVAIL; | 419 | rc = -EADDRNOTAVAIL; |
376 | kfree_skb(skb); | 420 | kfree_skb(skb); |
377 | goto error; | 421 | goto error; |
@@ -380,7 +424,8 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, | |||
380 | if (dev->ops->check_presence) | 424 | if (dev->ops->check_presence) |
381 | del_timer_sync(&dev->check_pres_timer); | 425 | del_timer_sync(&dev->check_pres_timer); |
382 | 426 | ||
383 | rc = dev->ops->data_exchange(dev, target_idx, skb, cb, cb_context); | 427 | rc = dev->ops->data_exchange(dev, dev->active_target, skb, cb, |
428 | cb_context); | ||
384 | 429 | ||
385 | if (!rc && dev->ops->check_presence) | 430 | if (!rc && dev->ops->check_presence) |
386 | mod_timer(&dev->check_pres_timer, jiffies + | 431 | mod_timer(&dev->check_pres_timer, jiffies + |
@@ -456,6 +501,9 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb); | |||
456 | * The device driver must call this function when one or many nfc targets | 501 | * The device driver must call this function when one or many nfc targets |
457 | * are found. After calling this function, the device driver must stop | 502 | * are found. After calling this function, the device driver must stop |
458 | * polling for targets. | 503 | * polling for targets. |
504 | * IMPORTANT: this function must not be called from an atomic context. | ||
505 | * In addition, it must also not be called from a context that would prevent | ||
506 | * the NFC Core to call other nfc ops entry point concurrently. | ||
459 | */ | 507 | */ |
460 | int nfc_targets_found(struct nfc_dev *dev, | 508 | int nfc_targets_found(struct nfc_dev *dev, |
461 | struct nfc_target *targets, int n_targets) | 509 | struct nfc_target *targets, int n_targets) |
@@ -469,7 +517,7 @@ int nfc_targets_found(struct nfc_dev *dev, | |||
469 | for (i = 0; i < n_targets; i++) | 517 | for (i = 0; i < n_targets; i++) |
470 | targets[i].idx = dev->target_next_idx++; | 518 | targets[i].idx = dev->target_next_idx++; |
471 | 519 | ||
472 | spin_lock_bh(&dev->targets_lock); | 520 | device_lock(&dev->dev); |
473 | 521 | ||
474 | dev->targets_generation++; | 522 | dev->targets_generation++; |
475 | 523 | ||
@@ -479,12 +527,12 @@ int nfc_targets_found(struct nfc_dev *dev, | |||
479 | 527 | ||
480 | if (!dev->targets) { | 528 | if (!dev->targets) { |
481 | dev->n_targets = 0; | 529 | dev->n_targets = 0; |
482 | spin_unlock_bh(&dev->targets_lock); | 530 | device_unlock(&dev->dev); |
483 | return -ENOMEM; | 531 | return -ENOMEM; |
484 | } | 532 | } |
485 | 533 | ||
486 | dev->n_targets = n_targets; | 534 | dev->n_targets = n_targets; |
487 | spin_unlock_bh(&dev->targets_lock); | 535 | device_unlock(&dev->dev); |
488 | 536 | ||
489 | nfc_genl_targets_found(dev); | 537 | nfc_genl_targets_found(dev); |
490 | 538 | ||
@@ -492,6 +540,18 @@ int nfc_targets_found(struct nfc_dev *dev, | |||
492 | } | 540 | } |
493 | EXPORT_SYMBOL(nfc_targets_found); | 541 | EXPORT_SYMBOL(nfc_targets_found); |
494 | 542 | ||
543 | /** | ||
544 | * nfc_target_lost - inform that an activated target went out of field | ||
545 | * | ||
546 | * @dev: The nfc device that had the activated target in field | ||
547 | * @target_idx: the nfc index of the target | ||
548 | * | ||
549 | * The device driver must call this function when the activated target | ||
550 | * goes out of the field. | ||
551 | * IMPORTANT: this function must not be called from an atomic context. | ||
552 | * In addition, it must also not be called from a context that would prevent | ||
553 | * the NFC Core to call other nfc ops entry point concurrently. | ||
554 | */ | ||
495 | int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) | 555 | int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) |
496 | { | 556 | { |
497 | struct nfc_target *tg; | 557 | struct nfc_target *tg; |
@@ -499,7 +559,7 @@ int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) | |||
499 | 559 | ||
500 | pr_debug("dev_name %s n_target %d\n", dev_name(&dev->dev), target_idx); | 560 | pr_debug("dev_name %s n_target %d\n", dev_name(&dev->dev), target_idx); |
501 | 561 | ||
502 | spin_lock_bh(&dev->targets_lock); | 562 | device_lock(&dev->dev); |
503 | 563 | ||
504 | for (i = 0; i < dev->n_targets; i++) { | 564 | for (i = 0; i < dev->n_targets; i++) { |
505 | tg = &dev->targets[i]; | 565 | tg = &dev->targets[i]; |
@@ -508,13 +568,13 @@ int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) | |||
508 | } | 568 | } |
509 | 569 | ||
510 | if (i == dev->n_targets) { | 570 | if (i == dev->n_targets) { |
511 | spin_unlock_bh(&dev->targets_lock); | 571 | device_unlock(&dev->dev); |
512 | return -EINVAL; | 572 | return -EINVAL; |
513 | } | 573 | } |
514 | 574 | ||
515 | dev->targets_generation++; | 575 | dev->targets_generation++; |
516 | dev->n_targets--; | 576 | dev->n_targets--; |
517 | dev->activated_target_idx = NFC_TARGET_IDX_NONE; | 577 | dev->active_target = NULL; |
518 | 578 | ||
519 | if (dev->n_targets) { | 579 | if (dev->n_targets) { |
520 | memcpy(&dev->targets[i], &dev->targets[i + 1], | 580 | memcpy(&dev->targets[i], &dev->targets[i + 1], |
@@ -524,7 +584,7 @@ int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) | |||
524 | dev->targets = NULL; | 584 | dev->targets = NULL; |
525 | } | 585 | } |
526 | 586 | ||
527 | spin_unlock_bh(&dev->targets_lock); | 587 | device_unlock(&dev->dev); |
528 | 588 | ||
529 | nfc_genl_target_lost(dev, target_idx); | 589 | nfc_genl_target_lost(dev, target_idx); |
530 | 590 | ||
@@ -556,15 +616,16 @@ static void nfc_check_pres_work(struct work_struct *work) | |||
556 | 616 | ||
557 | device_lock(&dev->dev); | 617 | device_lock(&dev->dev); |
558 | 618 | ||
559 | if (dev->activated_target_idx != NFC_TARGET_IDX_NONE && | 619 | if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) { |
560 | timer_pending(&dev->check_pres_timer) == 0) { | 620 | rc = dev->ops->check_presence(dev, dev->active_target); |
561 | rc = dev->ops->check_presence(dev, dev->activated_target_idx); | ||
562 | if (!rc) { | 621 | if (!rc) { |
563 | mod_timer(&dev->check_pres_timer, jiffies + | 622 | mod_timer(&dev->check_pres_timer, jiffies + |
564 | msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS)); | 623 | msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS)); |
565 | } else { | 624 | } else { |
566 | nfc_target_lost(dev, dev->activated_target_idx); | 625 | u32 active_target_idx = dev->active_target->idx; |
567 | dev->activated_target_idx = NFC_TARGET_IDX_NONE; | 626 | device_unlock(&dev->dev); |
627 | nfc_target_lost(dev, active_target_idx); | ||
628 | return; | ||
568 | } | 629 | } |
569 | } | 630 | } |
570 | 631 | ||
@@ -637,14 +698,12 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, | |||
637 | dev->tx_headroom = tx_headroom; | 698 | dev->tx_headroom = tx_headroom; |
638 | dev->tx_tailroom = tx_tailroom; | 699 | dev->tx_tailroom = tx_tailroom; |
639 | 700 | ||
640 | spin_lock_init(&dev->targets_lock); | ||
641 | nfc_genl_data_init(&dev->genl_data); | 701 | nfc_genl_data_init(&dev->genl_data); |
642 | 702 | ||
703 | |||
643 | /* first generation must not be 0 */ | 704 | /* first generation must not be 0 */ |
644 | dev->targets_generation = 1; | 705 | dev->targets_generation = 1; |
645 | 706 | ||
646 | dev->activated_target_idx = NFC_TARGET_IDX_NONE; | ||
647 | |||
648 | if (ops->check_presence) { | 707 | if (ops->check_presence) { |
649 | char name[32]; | 708 | char name[32]; |
650 | init_timer(&dev->check_pres_timer); | 709 | init_timer(&dev->check_pres_timer); |
@@ -662,7 +721,6 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, | |||
662 | } | 721 | } |
663 | } | 722 | } |
664 | 723 | ||
665 | |||
666 | return dev; | 724 | return dev; |
667 | } | 725 | } |
668 | EXPORT_SYMBOL(nfc_allocate_device); | 726 | EXPORT_SYMBOL(nfc_allocate_device); |
diff --git a/net/nfc/hci/Kconfig b/net/nfc/hci/Kconfig index 17213a6362b4..fd67f51d18e9 100644 --- a/net/nfc/hci/Kconfig +++ b/net/nfc/hci/Kconfig | |||
@@ -9,6 +9,7 @@ config NFC_HCI | |||
9 | 9 | ||
10 | config NFC_SHDLC | 10 | config NFC_SHDLC |
11 | depends on NFC_HCI | 11 | depends on NFC_HCI |
12 | select CRC_CCITT | ||
12 | bool "SHDLC link layer for HCI based NFC drivers" | 13 | bool "SHDLC link layer for HCI based NFC drivers" |
13 | default n | 14 | default n |
14 | ---help--- | 15 | ---help--- |
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index 86fd00d5a099..e1a640d2b588 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -235,13 +235,6 @@ static int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate) | |||
235 | targets->hci_reader_gate = gate; | 235 | targets->hci_reader_gate = gate; |
236 | 236 | ||
237 | r = nfc_targets_found(hdev->ndev, targets, 1); | 237 | r = nfc_targets_found(hdev->ndev, targets, 1); |
238 | if (r < 0) | ||
239 | goto exit; | ||
240 | |||
241 | kfree(hdev->targets); | ||
242 | hdev->targets = targets; | ||
243 | targets = NULL; | ||
244 | hdev->target_count = 1; | ||
245 | 238 | ||
246 | exit: | 239 | exit: |
247 | kfree(targets); | 240 | kfree(targets); |
@@ -258,11 +251,6 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, | |||
258 | 251 | ||
259 | switch (event) { | 252 | switch (event) { |
260 | case NFC_HCI_EVT_TARGET_DISCOVERED: | 253 | case NFC_HCI_EVT_TARGET_DISCOVERED: |
261 | if (hdev->poll_started == false) { | ||
262 | r = -EPROTO; | ||
263 | goto exit; | ||
264 | } | ||
265 | |||
266 | if (skb->len < 1) { /* no status data? */ | 254 | if (skb->len < 1) { /* no status data? */ |
267 | r = -EPROTO; | 255 | r = -EPROTO; |
268 | goto exit; | 256 | goto exit; |
@@ -496,74 +484,42 @@ static int hci_dev_down(struct nfc_dev *nfc_dev) | |||
496 | static int hci_start_poll(struct nfc_dev *nfc_dev, u32 protocols) | 484 | static int hci_start_poll(struct nfc_dev *nfc_dev, u32 protocols) |
497 | { | 485 | { |
498 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | 486 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
499 | int r; | ||
500 | 487 | ||
501 | if (hdev->ops->start_poll) | 488 | if (hdev->ops->start_poll) |
502 | r = hdev->ops->start_poll(hdev, protocols); | 489 | return hdev->ops->start_poll(hdev, protocols); |
503 | else | 490 | else |
504 | r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, | 491 | return nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, |
505 | NFC_HCI_EVT_READER_REQUESTED, NULL, 0); | 492 | NFC_HCI_EVT_READER_REQUESTED, NULL, 0); |
506 | if (r == 0) | ||
507 | hdev->poll_started = true; | ||
508 | |||
509 | return r; | ||
510 | } | 493 | } |
511 | 494 | ||
512 | static void hci_stop_poll(struct nfc_dev *nfc_dev) | 495 | static void hci_stop_poll(struct nfc_dev *nfc_dev) |
513 | { | 496 | { |
514 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | 497 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
515 | 498 | ||
516 | if (hdev->poll_started) { | 499 | nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, |
517 | nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, | 500 | NFC_HCI_EVT_END_OPERATION, NULL, 0); |
518 | NFC_HCI_EVT_END_OPERATION, NULL, 0); | ||
519 | hdev->poll_started = false; | ||
520 | } | ||
521 | } | ||
522 | |||
523 | static struct nfc_target *hci_find_target(struct nfc_hci_dev *hdev, | ||
524 | u32 target_idx) | ||
525 | { | ||
526 | int i; | ||
527 | if (hdev->poll_started == false || hdev->targets == NULL) | ||
528 | return NULL; | ||
529 | |||
530 | for (i = 0; i < hdev->target_count; i++) { | ||
531 | if (hdev->targets[i].idx == target_idx) | ||
532 | return &hdev->targets[i]; | ||
533 | } | ||
534 | |||
535 | return NULL; | ||
536 | } | 501 | } |
537 | 502 | ||
538 | static int hci_activate_target(struct nfc_dev *nfc_dev, u32 target_idx, | 503 | static int hci_activate_target(struct nfc_dev *nfc_dev, |
539 | u32 protocol) | 504 | struct nfc_target *target, u32 protocol) |
540 | { | 505 | { |
541 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | ||
542 | |||
543 | if (hci_find_target(hdev, target_idx) == NULL) | ||
544 | return -ENOMEDIUM; | ||
545 | |||
546 | return 0; | 506 | return 0; |
547 | } | 507 | } |
548 | 508 | ||
549 | static void hci_deactivate_target(struct nfc_dev *nfc_dev, u32 target_idx) | 509 | static void hci_deactivate_target(struct nfc_dev *nfc_dev, |
510 | struct nfc_target *target) | ||
550 | { | 511 | { |
551 | } | 512 | } |
552 | 513 | ||
553 | static int hci_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx, | 514 | static int hci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target, |
554 | struct sk_buff *skb, data_exchange_cb_t cb, | 515 | struct sk_buff *skb, data_exchange_cb_t cb, |
555 | void *cb_context) | 516 | void *cb_context) |
556 | { | 517 | { |
557 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | 518 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
558 | int r; | 519 | int r; |
559 | struct nfc_target *target; | ||
560 | struct sk_buff *res_skb = NULL; | 520 | struct sk_buff *res_skb = NULL; |
561 | 521 | ||
562 | pr_debug("target_idx=%d\n", target_idx); | 522 | pr_debug("target_idx=%d\n", target->idx); |
563 | |||
564 | target = hci_find_target(hdev, target_idx); | ||
565 | if (target == NULL) | ||
566 | return -ENOMEDIUM; | ||
567 | 523 | ||
568 | switch (target->hci_reader_gate) { | 524 | switch (target->hci_reader_gate) { |
569 | case NFC_HCI_RF_READER_A_GATE: | 525 | case NFC_HCI_RF_READER_A_GATE: |
@@ -605,7 +561,18 @@ static int hci_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx, | |||
605 | return 0; | 561 | return 0; |
606 | } | 562 | } |
607 | 563 | ||
608 | struct nfc_ops hci_nfc_ops = { | 564 | static int hci_check_presence(struct nfc_dev *nfc_dev, |
565 | struct nfc_target *target) | ||
566 | { | ||
567 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | ||
568 | |||
569 | if (hdev->ops->check_presence) | ||
570 | return hdev->ops->check_presence(hdev, target); | ||
571 | |||
572 | return 0; | ||
573 | } | ||
574 | |||
575 | static struct nfc_ops hci_nfc_ops = { | ||
609 | .dev_up = hci_dev_up, | 576 | .dev_up = hci_dev_up, |
610 | .dev_down = hci_dev_down, | 577 | .dev_down = hci_dev_down, |
611 | .start_poll = hci_start_poll, | 578 | .start_poll = hci_start_poll, |
@@ -613,6 +580,7 @@ struct nfc_ops hci_nfc_ops = { | |||
613 | .activate_target = hci_activate_target, | 580 | .activate_target = hci_activate_target, |
614 | .deactivate_target = hci_deactivate_target, | 581 | .deactivate_target = hci_deactivate_target, |
615 | .data_exchange = hci_data_exchange, | 582 | .data_exchange = hci_data_exchange, |
583 | .check_presence = hci_check_presence, | ||
616 | }; | 584 | }; |
617 | 585 | ||
618 | struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, | 586 | struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, |
diff --git a/net/nfc/hci/shdlc.c b/net/nfc/hci/shdlc.c index 923bdf7c26d6..5665dc6d893a 100644 --- a/net/nfc/hci/shdlc.c +++ b/net/nfc/hci/shdlc.c | |||
@@ -816,6 +816,17 @@ static int nfc_shdlc_data_exchange(struct nfc_hci_dev *hdev, | |||
816 | return -EPERM; | 816 | return -EPERM; |
817 | } | 817 | } |
818 | 818 | ||
819 | static int nfc_shdlc_check_presence(struct nfc_hci_dev *hdev, | ||
820 | struct nfc_target *target) | ||
821 | { | ||
822 | struct nfc_shdlc *shdlc = nfc_hci_get_clientdata(hdev); | ||
823 | |||
824 | if (shdlc->ops->check_presence) | ||
825 | return shdlc->ops->check_presence(shdlc, target); | ||
826 | |||
827 | return 0; | ||
828 | } | ||
829 | |||
819 | static struct nfc_hci_ops shdlc_ops = { | 830 | static struct nfc_hci_ops shdlc_ops = { |
820 | .open = nfc_shdlc_open, | 831 | .open = nfc_shdlc_open, |
821 | .close = nfc_shdlc_close, | 832 | .close = nfc_shdlc_close, |
@@ -825,6 +836,7 @@ static struct nfc_hci_ops shdlc_ops = { | |||
825 | .target_from_gate = nfc_shdlc_target_from_gate, | 836 | .target_from_gate = nfc_shdlc_target_from_gate, |
826 | .complete_target_discovered = nfc_shdlc_complete_target_discovered, | 837 | .complete_target_discovered = nfc_shdlc_complete_target_discovered, |
827 | .data_exchange = nfc_shdlc_data_exchange, | 838 | .data_exchange = nfc_shdlc_data_exchange, |
839 | .check_presence = nfc_shdlc_check_presence, | ||
828 | }; | 840 | }; |
829 | 841 | ||
830 | struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops, | 842 | struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops, |
diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index 11a3b7d98dc5..bf8ae4f0b90c 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c | |||
@@ -488,7 +488,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | |||
488 | 488 | ||
489 | memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len); | 489 | memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len); |
490 | 490 | ||
491 | skb_queue_head(&sock->tx_queue, pdu); | 491 | skb_queue_tail(&sock->tx_queue, pdu); |
492 | 492 | ||
493 | lock_sock(sk); | 493 | lock_sock(sk); |
494 | 494 | ||
@@ -502,7 +502,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | |||
502 | 502 | ||
503 | kfree(msg_data); | 503 | kfree(msg_data); |
504 | 504 | ||
505 | return 0; | 505 | return len; |
506 | } | 506 | } |
507 | 507 | ||
508 | int nfc_llcp_send_rr(struct nfc_llcp_sock *sock) | 508 | int nfc_llcp_send_rr(struct nfc_llcp_sock *sock) |
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index 92988aa620dc..42994fac26d6 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c | |||
@@ -448,6 +448,8 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, | |||
448 | { | 448 | { |
449 | struct nfc_llcp_sock *sock, *llcp_sock, *n; | 449 | struct nfc_llcp_sock *sock, *llcp_sock, *n; |
450 | 450 | ||
451 | pr_debug("ssap dsap %d %d\n", ssap, dsap); | ||
452 | |||
451 | if (ssap == 0 && dsap == 0) | 453 | if (ssap == 0 && dsap == 0) |
452 | return NULL; | 454 | return NULL; |
453 | 455 | ||
@@ -783,6 +785,7 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, | |||
783 | static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb) | 785 | static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb) |
784 | { | 786 | { |
785 | struct nfc_llcp_sock *llcp_sock; | 787 | struct nfc_llcp_sock *llcp_sock; |
788 | struct sock *sk; | ||
786 | u8 dsap, ssap; | 789 | u8 dsap, ssap; |
787 | 790 | ||
788 | dsap = nfc_llcp_dsap(skb); | 791 | dsap = nfc_llcp_dsap(skb); |
@@ -801,10 +804,14 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb) | |||
801 | } | 804 | } |
802 | 805 | ||
803 | llcp_sock->dsap = ssap; | 806 | llcp_sock->dsap = ssap; |
807 | sk = &llcp_sock->sk; | ||
804 | 808 | ||
805 | nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], | 809 | nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE], |
806 | skb->len - LLCP_HEADER_SIZE); | 810 | skb->len - LLCP_HEADER_SIZE); |
807 | 811 | ||
812 | sk->sk_state = LLCP_CONNECTED; | ||
813 | sk->sk_state_change(sk); | ||
814 | |||
808 | nfc_llcp_sock_put(llcp_sock); | 815 | nfc_llcp_sock_put(llcp_sock); |
809 | } | 816 | } |
810 | 817 | ||
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index c13e02ebdef9..3f339b19d140 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c | |||
@@ -27,6 +27,42 @@ | |||
27 | #include "../nfc.h" | 27 | #include "../nfc.h" |
28 | #include "llcp.h" | 28 | #include "llcp.h" |
29 | 29 | ||
30 | static int sock_wait_state(struct sock *sk, int state, unsigned long timeo) | ||
31 | { | ||
32 | DECLARE_WAITQUEUE(wait, current); | ||
33 | int err = 0; | ||
34 | |||
35 | pr_debug("sk %p", sk); | ||
36 | |||
37 | add_wait_queue(sk_sleep(sk), &wait); | ||
38 | set_current_state(TASK_INTERRUPTIBLE); | ||
39 | |||
40 | while (sk->sk_state != state) { | ||
41 | if (!timeo) { | ||
42 | err = -EINPROGRESS; | ||
43 | break; | ||
44 | } | ||
45 | |||
46 | if (signal_pending(current)) { | ||
47 | err = sock_intr_errno(timeo); | ||
48 | break; | ||
49 | } | ||
50 | |||
51 | release_sock(sk); | ||
52 | timeo = schedule_timeout(timeo); | ||
53 | lock_sock(sk); | ||
54 | set_current_state(TASK_INTERRUPTIBLE); | ||
55 | |||
56 | err = sock_error(sk); | ||
57 | if (err) | ||
58 | break; | ||
59 | } | ||
60 | |||
61 | __set_current_state(TASK_RUNNING); | ||
62 | remove_wait_queue(sk_sleep(sk), &wait); | ||
63 | return err; | ||
64 | } | ||
65 | |||
30 | static struct proto llcp_sock_proto = { | 66 | static struct proto llcp_sock_proto = { |
31 | .name = "NFC_LLCP", | 67 | .name = "NFC_LLCP", |
32 | .owner = THIS_MODULE, | 68 | .owner = THIS_MODULE, |
@@ -304,11 +340,24 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock, | |||
304 | mask |= POLLERR; | 340 | mask |= POLLERR; |
305 | 341 | ||
306 | if (!skb_queue_empty(&sk->sk_receive_queue)) | 342 | if (!skb_queue_empty(&sk->sk_receive_queue)) |
307 | mask |= POLLIN; | 343 | mask |= POLLIN | POLLRDNORM; |
308 | 344 | ||
309 | if (sk->sk_state == LLCP_CLOSED) | 345 | if (sk->sk_state == LLCP_CLOSED) |
310 | mask |= POLLHUP; | 346 | mask |= POLLHUP; |
311 | 347 | ||
348 | if (sk->sk_shutdown & RCV_SHUTDOWN) | ||
349 | mask |= POLLRDHUP | POLLIN | POLLRDNORM; | ||
350 | |||
351 | if (sk->sk_shutdown == SHUTDOWN_MASK) | ||
352 | mask |= POLLHUP; | ||
353 | |||
354 | if (sock_writeable(sk)) | ||
355 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; | ||
356 | else | ||
357 | set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); | ||
358 | |||
359 | pr_debug("mask 0x%x\n", mask); | ||
360 | |||
312 | return mask; | 361 | return mask; |
313 | } | 362 | } |
314 | 363 | ||
@@ -462,9 +511,13 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, | |||
462 | if (ret) | 511 | if (ret) |
463 | goto put_dev; | 512 | goto put_dev; |
464 | 513 | ||
465 | sk->sk_state = LLCP_CONNECTED; | 514 | ret = sock_wait_state(sk, LLCP_CONNECTED, |
515 | sock_sndtimeo(sk, flags & O_NONBLOCK)); | ||
516 | if (ret) | ||
517 | goto put_dev; | ||
466 | 518 | ||
467 | release_sock(sk); | 519 | release_sock(sk); |
520 | |||
468 | return 0; | 521 | return 0; |
469 | 522 | ||
470 | put_dev: | 523 | put_dev: |
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index 8737c2089fdd..d560e6f13072 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -436,16 +436,16 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev) | |||
436 | msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); | 436 | msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); |
437 | } | 437 | } |
438 | 438 | ||
439 | static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, | 439 | static int nci_activate_target(struct nfc_dev *nfc_dev, |
440 | __u32 protocol) | 440 | struct nfc_target *target, __u32 protocol) |
441 | { | 441 | { |
442 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 442 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
443 | struct nci_rf_discover_select_param param; | 443 | struct nci_rf_discover_select_param param; |
444 | struct nfc_target *target = NULL; | 444 | struct nfc_target *nci_target = NULL; |
445 | int i; | 445 | int i; |
446 | int rc = 0; | 446 | int rc = 0; |
447 | 447 | ||
448 | pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol); | 448 | pr_debug("target_idx %d, protocol 0x%x\n", target->idx, protocol); |
449 | 449 | ||
450 | if ((atomic_read(&ndev->state) != NCI_W4_HOST_SELECT) && | 450 | if ((atomic_read(&ndev->state) != NCI_W4_HOST_SELECT) && |
451 | (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { | 451 | (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { |
@@ -459,25 +459,25 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, | |||
459 | } | 459 | } |
460 | 460 | ||
461 | for (i = 0; i < ndev->n_targets; i++) { | 461 | for (i = 0; i < ndev->n_targets; i++) { |
462 | if (ndev->targets[i].idx == target_idx) { | 462 | if (ndev->targets[i].idx == target->idx) { |
463 | target = &ndev->targets[i]; | 463 | nci_target = &ndev->targets[i]; |
464 | break; | 464 | break; |
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | if (!target) { | 468 | if (!nci_target) { |
469 | pr_err("unable to find the selected target\n"); | 469 | pr_err("unable to find the selected target\n"); |
470 | return -EINVAL; | 470 | return -EINVAL; |
471 | } | 471 | } |
472 | 472 | ||
473 | if (!(target->supported_protocols & (1 << protocol))) { | 473 | if (!(nci_target->supported_protocols & (1 << protocol))) { |
474 | pr_err("target does not support the requested protocol 0x%x\n", | 474 | pr_err("target does not support the requested protocol 0x%x\n", |
475 | protocol); | 475 | protocol); |
476 | return -EINVAL; | 476 | return -EINVAL; |
477 | } | 477 | } |
478 | 478 | ||
479 | if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) { | 479 | if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) { |
480 | param.rf_discovery_id = target->logical_idx; | 480 | param.rf_discovery_id = nci_target->logical_idx; |
481 | 481 | ||
482 | if (protocol == NFC_PROTO_JEWEL) | 482 | if (protocol == NFC_PROTO_JEWEL) |
483 | param.rf_protocol = NCI_RF_PROTOCOL_T1T; | 483 | param.rf_protocol = NCI_RF_PROTOCOL_T1T; |
@@ -501,11 +501,12 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, | |||
501 | return rc; | 501 | return rc; |
502 | } | 502 | } |
503 | 503 | ||
504 | static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx) | 504 | static void nci_deactivate_target(struct nfc_dev *nfc_dev, |
505 | struct nfc_target *target) | ||
505 | { | 506 | { |
506 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 507 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
507 | 508 | ||
508 | pr_debug("target_idx %d\n", target_idx); | 509 | pr_debug("target_idx %d\n", target->idx); |
509 | 510 | ||
510 | if (!ndev->target_active_prot) { | 511 | if (!ndev->target_active_prot) { |
511 | pr_err("unable to deactivate target, no active target\n"); | 512 | pr_err("unable to deactivate target, no active target\n"); |
@@ -520,14 +521,14 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx) | |||
520 | } | 521 | } |
521 | } | 522 | } |
522 | 523 | ||
523 | static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx, | 524 | static int nci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target, |
524 | struct sk_buff *skb, | 525 | struct sk_buff *skb, |
525 | data_exchange_cb_t cb, void *cb_context) | 526 | data_exchange_cb_t cb, void *cb_context) |
526 | { | 527 | { |
527 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 528 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
528 | int rc; | 529 | int rc; |
529 | 530 | ||
530 | pr_debug("target_idx %d, len %d\n", target_idx, skb->len); | 531 | pr_debug("target_idx %d, len %d\n", target->idx, skb->len); |
531 | 532 | ||
532 | if (!ndev->target_active_prot) { | 533 | if (!ndev->target_active_prot) { |
533 | pr_err("unable to exchange data, no active target\n"); | 534 | pr_err("unable to exchange data, no active target\n"); |
diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c index a0bc326308a5..76c48c5324f8 100644 --- a/net/nfc/nci/data.c +++ b/net/nfc/nci/data.c | |||
@@ -49,7 +49,7 @@ void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, | |||
49 | 49 | ||
50 | if (cb) { | 50 | if (cb) { |
51 | ndev->data_exchange_cb = NULL; | 51 | ndev->data_exchange_cb = NULL; |
52 | ndev->data_exchange_cb_context = 0; | 52 | ndev->data_exchange_cb_context = NULL; |
53 | 53 | ||
54 | /* forward skb to nfc core */ | 54 | /* forward skb to nfc core */ |
55 | cb(cb_context, skb, err); | 55 | cb(cb_context, skb, err); |
@@ -200,10 +200,10 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev, | |||
200 | pr_err("error adding room for accumulated rx data\n"); | 200 | pr_err("error adding room for accumulated rx data\n"); |
201 | 201 | ||
202 | kfree_skb(skb); | 202 | kfree_skb(skb); |
203 | skb = 0; | 203 | skb = NULL; |
204 | 204 | ||
205 | kfree_skb(ndev->rx_data_reassembly); | 205 | kfree_skb(ndev->rx_data_reassembly); |
206 | ndev->rx_data_reassembly = 0; | 206 | ndev->rx_data_reassembly = NULL; |
207 | 207 | ||
208 | err = -ENOMEM; | 208 | err = -ENOMEM; |
209 | goto exit; | 209 | goto exit; |
@@ -216,7 +216,7 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev, | |||
216 | 216 | ||
217 | /* third, free old reassembly */ | 217 | /* third, free old reassembly */ |
218 | kfree_skb(ndev->rx_data_reassembly); | 218 | kfree_skb(ndev->rx_data_reassembly); |
219 | ndev->rx_data_reassembly = 0; | 219 | ndev->rx_data_reassembly = NULL; |
220 | } | 220 | } |
221 | 221 | ||
222 | if (pbf == NCI_PBF_CONT) { | 222 | if (pbf == NCI_PBF_CONT) { |
diff --git a/net/nfc/nci/lib.c b/net/nfc/nci/lib.c index 6a63e5eb483d..6b7fd26c68d9 100644 --- a/net/nfc/nci/lib.c +++ b/net/nfc/nci/lib.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
32 | 32 | ||
33 | #include <net/nfc/nci.h> | 33 | #include <net/nfc/nci.h> |
34 | #include <net/nfc/nci_core.h> | ||
34 | 35 | ||
35 | /* NCI status codes to Unix errno mapping */ | 36 | /* NCI status codes to Unix errno mapping */ |
36 | int nci_to_errno(__u8 code) | 37 | int nci_to_errno(__u8 code) |
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c index 99e1632e6aac..cb2646179e5f 100644 --- a/net/nfc/nci/ntf.c +++ b/net/nfc/nci/ntf.c | |||
@@ -497,7 +497,7 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, | |||
497 | /* drop partial rx data packet */ | 497 | /* drop partial rx data packet */ |
498 | if (ndev->rx_data_reassembly) { | 498 | if (ndev->rx_data_reassembly) { |
499 | kfree_skb(ndev->rx_data_reassembly); | 499 | kfree_skb(ndev->rx_data_reassembly); |
500 | ndev->rx_data_reassembly = 0; | 500 | ndev->rx_data_reassembly = NULL; |
501 | } | 501 | } |
502 | 502 | ||
503 | /* complete the data exchange transaction, if exists */ | 503 | /* complete the data exchange transaction, if exists */ |
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index f1829f6ae9c5..581d419083aa 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c | |||
@@ -33,7 +33,7 @@ static struct genl_multicast_group nfc_genl_event_mcgrp = { | |||
33 | .name = NFC_GENL_MCAST_EVENT_NAME, | 33 | .name = NFC_GENL_MCAST_EVENT_NAME, |
34 | }; | 34 | }; |
35 | 35 | ||
36 | struct genl_family nfc_genl_family = { | 36 | static struct genl_family nfc_genl_family = { |
37 | .id = GENL_ID_GENERATE, | 37 | .id = GENL_ID_GENERATE, |
38 | .hdrsize = 0, | 38 | .hdrsize = 0, |
39 | .name = NFC_GENL_NAME, | 39 | .name = NFC_GENL_NAME, |
@@ -128,7 +128,7 @@ static int nfc_genl_dump_targets(struct sk_buff *skb, | |||
128 | cb->args[1] = (long) dev; | 128 | cb->args[1] = (long) dev; |
129 | } | 129 | } |
130 | 130 | ||
131 | spin_lock_bh(&dev->targets_lock); | 131 | device_lock(&dev->dev); |
132 | 132 | ||
133 | cb->seq = dev->targets_generation; | 133 | cb->seq = dev->targets_generation; |
134 | 134 | ||
@@ -141,7 +141,7 @@ static int nfc_genl_dump_targets(struct sk_buff *skb, | |||
141 | i++; | 141 | i++; |
142 | } | 142 | } |
143 | 143 | ||
144 | spin_unlock_bh(&dev->targets_lock); | 144 | device_unlock(&dev->dev); |
145 | 145 | ||
146 | cb->args[0] = i; | 146 | cb->args[0] = i; |
147 | 147 | ||
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index 7d589a81942e..3dd4232ae664 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h | |||
@@ -84,7 +84,7 @@ static inline int nfc_llcp_set_remote_gb(struct nfc_dev *dev, | |||
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
86 | 86 | ||
87 | static inline u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, u8 *gb_len) | 87 | static inline u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *gb_len) |
88 | { | 88 | { |
89 | *gb_len = 0; | 89 | *gb_len = 0; |
90 | return NULL; | 90 | return NULL; |