aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/nci
diff options
context:
space:
mode:
Diffstat (limited to 'net/nfc/nci')
-rw-r--r--net/nfc/nci/core.c103
-rw-r--r--net/nfc/nci/data.c35
-rw-r--r--net/nfc/nci/lib.c8
-rw-r--r--net/nfc/nci/ntf.c187
-rw-r--r--net/nfc/nci/rsp.c137
5 files changed, 236 insertions, 234 deletions
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 25dae3f8f5c2..c55f233a5e2c 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -25,9 +25,12 @@
25 * 25 *
26 */ 26 */
27 27
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29
28#include <linux/types.h> 30#include <linux/types.h>
29#include <linux/workqueue.h> 31#include <linux/workqueue.h>
30#include <linux/completion.h> 32#include <linux/completion.h>
33#include <linux/export.h>
31#include <linux/sched.h> 34#include <linux/sched.h>
32#include <linux/bitops.h> 35#include <linux/bitops.h>
33#include <linux/skbuff.h> 36#include <linux/skbuff.h>
@@ -78,7 +81,7 @@ static int __nci_request(struct nci_dev *ndev,
78 &ndev->req_completion, 81 &ndev->req_completion,
79 timeout); 82 timeout);
80 83
81 nfc_dbg("wait_for_completion return %ld", completion_rc); 84 pr_debug("wait_for_completion return %ld\n", completion_rc);
82 85
83 if (completion_rc > 0) { 86 if (completion_rc > 0) {
84 switch (ndev->req_status) { 87 switch (ndev->req_status) {
@@ -95,8 +98,8 @@ static int __nci_request(struct nci_dev *ndev,
95 break; 98 break;
96 } 99 }
97 } else { 100 } else {
98 nfc_err("wait_for_completion_interruptible_timeout failed %ld", 101 pr_err("wait_for_completion_interruptible_timeout failed %ld\n",
99 completion_rc); 102 completion_rc);
100 103
101 rc = ((completion_rc == 0) ? (-ETIMEDOUT) : (completion_rc)); 104 rc = ((completion_rc == 0) ? (-ETIMEDOUT) : (completion_rc));
102 } 105 }
@@ -125,7 +128,10 @@ static inline int nci_request(struct nci_dev *ndev,
125 128
126static void nci_reset_req(struct nci_dev *ndev, unsigned long opt) 129static void nci_reset_req(struct nci_dev *ndev, unsigned long opt)
127{ 130{
128 nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 0, NULL); 131 struct nci_core_reset_cmd cmd;
132
133 cmd.reset_type = NCI_RESET_TYPE_RESET_CONFIG;
134 nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 1, &cmd);
129} 135}
130 136
131static void nci_init_req(struct nci_dev *ndev, unsigned long opt) 137static void nci_init_req(struct nci_dev *ndev, unsigned long opt)
@@ -135,17 +141,11 @@ static void nci_init_req(struct nci_dev *ndev, unsigned long opt)
135 141
136static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt) 142static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt)
137{ 143{
138 struct nci_core_conn_create_cmd conn_cmd;
139 struct nci_rf_disc_map_cmd cmd; 144 struct nci_rf_disc_map_cmd cmd;
140 struct disc_map_config *cfg = cmd.mapping_configs; 145 struct disc_map_config *cfg = cmd.mapping_configs;
141 __u8 *num = &cmd.num_mapping_configs; 146 __u8 *num = &cmd.num_mapping_configs;
142 int i; 147 int i;
143 148
144 /* create static rf connection */
145 conn_cmd.target_handle = 0;
146 conn_cmd.num_target_specific_params = 0;
147 nci_send_cmd(ndev, NCI_OP_CORE_CONN_CREATE_CMD, 2, &conn_cmd);
148
149 /* set rf mapping configurations */ 149 /* set rf mapping configurations */
150 *num = 0; 150 *num = 0;
151 151
@@ -325,8 +325,6 @@ static void nci_cmd_timer(unsigned long arg)
325{ 325{
326 struct nci_dev *ndev = (void *) arg; 326 struct nci_dev *ndev = (void *) arg;
327 327
328 nfc_dbg("entry");
329
330 atomic_set(&ndev->cmd_cnt, 1); 328 atomic_set(&ndev->cmd_cnt, 1);
331 queue_work(ndev->cmd_wq, &ndev->cmd_work); 329 queue_work(ndev->cmd_wq, &ndev->cmd_work);
332} 330}
@@ -335,8 +333,6 @@ static int nci_dev_up(struct nfc_dev *nfc_dev)
335{ 333{
336 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 334 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
337 335
338 nfc_dbg("entry");
339
340 return nci_open_device(ndev); 336 return nci_open_device(ndev);
341} 337}
342 338
@@ -344,8 +340,6 @@ static int nci_dev_down(struct nfc_dev *nfc_dev)
344{ 340{
345 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 341 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
346 342
347 nfc_dbg("entry");
348
349 return nci_close_device(ndev); 343 return nci_close_device(ndev);
350} 344}
351 345
@@ -354,20 +348,18 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols)
354 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 348 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
355 int rc; 349 int rc;
356 350
357 nfc_dbg("entry");
358
359 if (test_bit(NCI_DISCOVERY, &ndev->flags)) { 351 if (test_bit(NCI_DISCOVERY, &ndev->flags)) {
360 nfc_err("unable to start poll, since poll is already active"); 352 pr_err("unable to start poll, since poll is already active\n");
361 return -EBUSY; 353 return -EBUSY;
362 } 354 }
363 355
364 if (ndev->target_active_prot) { 356 if (ndev->target_active_prot) {
365 nfc_err("there is an active target"); 357 pr_err("there is an active target\n");
366 return -EBUSY; 358 return -EBUSY;
367 } 359 }
368 360
369 if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { 361 if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) {
370 nfc_dbg("target is active, implicitly deactivate..."); 362 pr_debug("target is active, implicitly deactivate...\n");
371 363
372 rc = nci_request(ndev, nci_rf_deactivate_req, 0, 364 rc = nci_request(ndev, nci_rf_deactivate_req, 0,
373 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); 365 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
@@ -388,10 +380,8 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev)
388{ 380{
389 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 381 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
390 382
391 nfc_dbg("entry");
392
393 if (!test_bit(NCI_DISCOVERY, &ndev->flags)) { 383 if (!test_bit(NCI_DISCOVERY, &ndev->flags)) {
394 nfc_err("unable to stop poll, since poll is not active"); 384 pr_err("unable to stop poll, since poll is not active\n");
395 return; 385 return;
396 } 386 }
397 387
@@ -404,21 +394,21 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx,
404{ 394{
405 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 395 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
406 396
407 nfc_dbg("entry, target_idx %d, protocol 0x%x", target_idx, protocol); 397 pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol);
408 398
409 if (!test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { 399 if (!test_bit(NCI_POLL_ACTIVE, &ndev->flags)) {
410 nfc_err("there is no available target to activate"); 400 pr_err("there is no available target to activate\n");
411 return -EINVAL; 401 return -EINVAL;
412 } 402 }
413 403
414 if (ndev->target_active_prot) { 404 if (ndev->target_active_prot) {
415 nfc_err("there is already an active target"); 405 pr_err("there is already an active target\n");
416 return -EBUSY; 406 return -EBUSY;
417 } 407 }
418 408
419 if (!(ndev->target_available_prots & (1 << protocol))) { 409 if (!(ndev->target_available_prots & (1 << protocol))) {
420 nfc_err("target does not support the requested protocol 0x%x", 410 pr_err("target does not support the requested protocol 0x%x\n",
421 protocol); 411 protocol);
422 return -EINVAL; 412 return -EINVAL;
423 } 413 }
424 414
@@ -432,10 +422,10 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx)
432{ 422{
433 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 423 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
434 424
435 nfc_dbg("entry, target_idx %d", target_idx); 425 pr_debug("target_idx %d\n", target_idx);
436 426
437 if (!ndev->target_active_prot) { 427 if (!ndev->target_active_prot) {
438 nfc_err("unable to deactivate target, no active target"); 428 pr_err("unable to deactivate target, no active target\n");
439 return; 429 return;
440 } 430 }
441 431
@@ -455,10 +445,10 @@ static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx,
455 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 445 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
456 int rc; 446 int rc;
457 447
458 nfc_dbg("entry, target_idx %d, len %d", target_idx, skb->len); 448 pr_debug("target_idx %d, len %d\n", target_idx, skb->len);
459 449
460 if (!ndev->target_active_prot) { 450 if (!ndev->target_active_prot) {
461 nfc_err("unable to exchange data, no active target"); 451 pr_err("unable to exchange data, no active target\n");
462 return -EINVAL; 452 return -EINVAL;
463 } 453 }
464 454
@@ -469,7 +459,7 @@ static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx,
469 ndev->data_exchange_cb = cb; 459 ndev->data_exchange_cb = cb;
470 ndev->data_exchange_cb_context = cb_context; 460 ndev->data_exchange_cb_context = cb_context;
471 461
472 rc = nci_send_data(ndev, ndev->conn_id, skb); 462 rc = nci_send_data(ndev, NCI_STATIC_RF_CONN_ID, skb);
473 if (rc) 463 if (rc)
474 clear_bit(NCI_DATA_EXCHANGE, &ndev->flags); 464 clear_bit(NCI_DATA_EXCHANGE, &ndev->flags);
475 465
@@ -501,7 +491,7 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops,
501{ 491{
502 struct nci_dev *ndev; 492 struct nci_dev *ndev;
503 493
504 nfc_dbg("entry, supported_protocols 0x%x", supported_protocols); 494 pr_debug("supported_protocols 0x%x\n", supported_protocols);
505 495
506 if (!ops->open || !ops->close || !ops->send) 496 if (!ops->open || !ops->close || !ops->send)
507 return NULL; 497 return NULL;
@@ -541,8 +531,6 @@ EXPORT_SYMBOL(nci_allocate_device);
541 */ 531 */
542void nci_free_device(struct nci_dev *ndev) 532void nci_free_device(struct nci_dev *ndev)
543{ 533{
544 nfc_dbg("entry");
545
546 nfc_free_device(ndev->nfc_dev); 534 nfc_free_device(ndev->nfc_dev);
547 kfree(ndev); 535 kfree(ndev);
548} 536}
@@ -559,8 +547,6 @@ int nci_register_device(struct nci_dev *ndev)
559 struct device *dev = &ndev->nfc_dev->dev; 547 struct device *dev = &ndev->nfc_dev->dev;
560 char name[32]; 548 char name[32];
561 549
562 nfc_dbg("entry");
563
564 rc = nfc_register_device(ndev->nfc_dev); 550 rc = nfc_register_device(ndev->nfc_dev);
565 if (rc) 551 if (rc)
566 goto exit; 552 goto exit;
@@ -623,8 +609,6 @@ EXPORT_SYMBOL(nci_register_device);
623 */ 609 */
624void nci_unregister_device(struct nci_dev *ndev) 610void nci_unregister_device(struct nci_dev *ndev)
625{ 611{
626 nfc_dbg("entry");
627
628 nci_close_device(ndev); 612 nci_close_device(ndev);
629 613
630 destroy_workqueue(ndev->cmd_wq); 614 destroy_workqueue(ndev->cmd_wq);
@@ -644,7 +628,7 @@ int nci_recv_frame(struct sk_buff *skb)
644{ 628{
645 struct nci_dev *ndev = (struct nci_dev *) skb->dev; 629 struct nci_dev *ndev = (struct nci_dev *) skb->dev;
646 630
647 nfc_dbg("entry, len %d", skb->len); 631 pr_debug("len %d\n", skb->len);
648 632
649 if (!ndev || (!test_bit(NCI_UP, &ndev->flags) 633 if (!ndev || (!test_bit(NCI_UP, &ndev->flags)
650 && !test_bit(NCI_INIT, &ndev->flags))) { 634 && !test_bit(NCI_INIT, &ndev->flags))) {
@@ -664,7 +648,7 @@ static int nci_send_frame(struct sk_buff *skb)
664{ 648{
665 struct nci_dev *ndev = (struct nci_dev *) skb->dev; 649 struct nci_dev *ndev = (struct nci_dev *) skb->dev;
666 650
667 nfc_dbg("entry, len %d", skb->len); 651 pr_debug("len %d\n", skb->len);
668 652
669 if (!ndev) { 653 if (!ndev) {
670 kfree_skb(skb); 654 kfree_skb(skb);
@@ -683,11 +667,11 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload)
683 struct nci_ctrl_hdr *hdr; 667 struct nci_ctrl_hdr *hdr;
684 struct sk_buff *skb; 668 struct sk_buff *skb;
685 669
686 nfc_dbg("entry, opcode 0x%x, plen %d", opcode, plen); 670 pr_debug("opcode 0x%x, plen %d\n", opcode, plen);
687 671
688 skb = nci_skb_alloc(ndev, (NCI_CTRL_HDR_SIZE + plen), GFP_KERNEL); 672 skb = nci_skb_alloc(ndev, (NCI_CTRL_HDR_SIZE + plen), GFP_KERNEL);
689 if (!skb) { 673 if (!skb) {
690 nfc_err("no memory for command"); 674 pr_err("no memory for command\n");
691 return -ENOMEM; 675 return -ENOMEM;
692 } 676 }
693 677
@@ -717,7 +701,7 @@ static void nci_tx_work(struct work_struct *work)
717 struct nci_dev *ndev = container_of(work, struct nci_dev, tx_work); 701 struct nci_dev *ndev = container_of(work, struct nci_dev, tx_work);
718 struct sk_buff *skb; 702 struct sk_buff *skb;
719 703
720 nfc_dbg("entry, credits_cnt %d", atomic_read(&ndev->credits_cnt)); 704 pr_debug("credits_cnt %d\n", atomic_read(&ndev->credits_cnt));
721 705
722 /* Send queued tx data */ 706 /* Send queued tx data */
723 while (atomic_read(&ndev->credits_cnt)) { 707 while (atomic_read(&ndev->credits_cnt)) {
@@ -725,12 +709,15 @@ static void nci_tx_work(struct work_struct *work)
725 if (!skb) 709 if (!skb)
726 return; 710 return;
727 711
728 atomic_dec(&ndev->credits_cnt); 712 /* Check if data flow control is used */
713 if (atomic_read(&ndev->credits_cnt) !=
714 NCI_DATA_FLOW_CONTROL_NOT_USED)
715 atomic_dec(&ndev->credits_cnt);
729 716
730 nfc_dbg("NCI TX: MT=data, PBF=%d, conn_id=%d, plen=%d", 717 pr_debug("NCI TX: MT=data, PBF=%d, conn_id=%d, plen=%d\n",
731 nci_pbf(skb->data), 718 nci_pbf(skb->data),
732 nci_conn_id(skb->data), 719 nci_conn_id(skb->data),
733 nci_plen(skb->data)); 720 nci_plen(skb->data));
734 721
735 nci_send_frame(skb); 722 nci_send_frame(skb);
736 } 723 }
@@ -759,7 +746,7 @@ static void nci_rx_work(struct work_struct *work)
759 break; 746 break;
760 747
761 default: 748 default:
762 nfc_err("unknown MT 0x%x", nci_mt(skb->data)); 749 pr_err("unknown MT 0x%x\n", nci_mt(skb->data));
763 kfree_skb(skb); 750 kfree_skb(skb);
764 break; 751 break;
765 } 752 }
@@ -773,7 +760,7 @@ static void nci_cmd_work(struct work_struct *work)
773 struct nci_dev *ndev = container_of(work, struct nci_dev, cmd_work); 760 struct nci_dev *ndev = container_of(work, struct nci_dev, cmd_work);
774 struct sk_buff *skb; 761 struct sk_buff *skb;
775 762
776 nfc_dbg("entry, cmd_cnt %d", atomic_read(&ndev->cmd_cnt)); 763 pr_debug("cmd_cnt %d\n", atomic_read(&ndev->cmd_cnt));
777 764
778 /* Send queued command */ 765 /* Send queued command */
779 if (atomic_read(&ndev->cmd_cnt)) { 766 if (atomic_read(&ndev->cmd_cnt)) {
@@ -783,11 +770,11 @@ static void nci_cmd_work(struct work_struct *work)
783 770
784 atomic_dec(&ndev->cmd_cnt); 771 atomic_dec(&ndev->cmd_cnt);
785 772
786 nfc_dbg("NCI TX: MT=cmd, PBF=%d, GID=0x%x, OID=0x%x, plen=%d", 773 pr_debug("NCI TX: MT=cmd, PBF=%d, GID=0x%x, OID=0x%x, plen=%d\n",
787 nci_pbf(skb->data), 774 nci_pbf(skb->data),
788 nci_opcode_gid(nci_opcode(skb->data)), 775 nci_opcode_gid(nci_opcode(skb->data)),
789 nci_opcode_oid(nci_opcode(skb->data)), 776 nci_opcode_oid(nci_opcode(skb->data)),
790 nci_plen(skb->data)); 777 nci_plen(skb->data));
791 778
792 nci_send_frame(skb); 779 nci_send_frame(skb);
793 780
diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c
index e5ed90fc1a9c..1e040feb2f84 100644
--- a/net/nfc/nci/data.c
+++ b/net/nfc/nci/data.c
@@ -21,6 +21,8 @@
21 * 21 *
22 */ 22 */
23 23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
24#include <linux/types.h> 26#include <linux/types.h>
25#include <linux/interrupt.h> 27#include <linux/interrupt.h>
26#include <linux/wait.h> 28#include <linux/wait.h>
@@ -40,7 +42,7 @@ void nci_data_exchange_complete(struct nci_dev *ndev,
40 data_exchange_cb_t cb = ndev->data_exchange_cb; 42 data_exchange_cb_t cb = ndev->data_exchange_cb;
41 void *cb_context = ndev->data_exchange_cb_context; 43 void *cb_context = ndev->data_exchange_cb_context;
42 44
43 nfc_dbg("entry, len %d, err %d", ((skb) ? (skb->len) : (0)), err); 45 pr_debug("len %d, err %d\n", skb ? skb->len : 0, err);
44 46
45 if (cb) { 47 if (cb) {
46 ndev->data_exchange_cb = NULL; 48 ndev->data_exchange_cb = NULL;
@@ -49,7 +51,7 @@ void nci_data_exchange_complete(struct nci_dev *ndev,
49 /* forward skb to nfc core */ 51 /* forward skb to nfc core */
50 cb(cb_context, skb, err); 52 cb(cb_context, skb, err);
51 } else if (skb) { 53 } else if (skb) {
52 nfc_err("no rx callback, dropping rx data..."); 54 pr_err("no rx callback, dropping rx data...\n");
53 55
54 /* no waiting callback, free skb */ 56 /* no waiting callback, free skb */
55 kfree_skb(skb); 57 kfree_skb(skb);
@@ -90,12 +92,13 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev,
90 int frag_len; 92 int frag_len;
91 int rc = 0; 93 int rc = 0;
92 94
93 nfc_dbg("entry, conn_id 0x%x, total_len %d", conn_id, total_len); 95 pr_debug("conn_id 0x%x, total_len %d\n", conn_id, total_len);
94 96
95 __skb_queue_head_init(&frags_q); 97 __skb_queue_head_init(&frags_q);
96 98
97 while (total_len) { 99 while (total_len) {
98 frag_len = min_t(int, total_len, ndev->max_pkt_payload_size); 100 frag_len =
101 min_t(int, total_len, ndev->max_data_pkt_payload_size);
99 102
100 skb_frag = nci_skb_alloc(ndev, 103 skb_frag = nci_skb_alloc(ndev,
101 (NCI_DATA_HDR_SIZE + frag_len), 104 (NCI_DATA_HDR_SIZE + frag_len),
@@ -118,8 +121,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev,
118 data += frag_len; 121 data += frag_len;
119 total_len -= frag_len; 122 total_len -= frag_len;
120 123
121 nfc_dbg("frag_len %d, remaining total_len %d", 124 pr_debug("frag_len %d, remaining total_len %d\n",
122 frag_len, total_len); 125 frag_len, total_len);
123 } 126 }
124 127
125 /* queue all fragments atomically */ 128 /* queue all fragments atomically */
@@ -148,10 +151,10 @@ int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb)
148{ 151{
149 int rc = 0; 152 int rc = 0;
150 153
151 nfc_dbg("entry, conn_id 0x%x, plen %d", conn_id, skb->len); 154 pr_debug("conn_id 0x%x, plen %d\n", conn_id, skb->len);
152 155
153 /* check if the packet need to be fragmented */ 156 /* check if the packet need to be fragmented */
154 if (skb->len <= ndev->max_pkt_payload_size) { 157 if (skb->len <= ndev->max_data_pkt_payload_size) {
155 /* no need to fragment packet */ 158 /* no need to fragment packet */
156 nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST); 159 nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST);
157 160
@@ -160,7 +163,7 @@ int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb)
160 /* fragment packet and queue the fragments */ 163 /* fragment packet and queue the fragments */
161 rc = nci_queue_tx_data_frags(ndev, conn_id, skb); 164 rc = nci_queue_tx_data_frags(ndev, conn_id, skb);
162 if (rc) { 165 if (rc) {
163 nfc_err("failed to fragment tx data packet"); 166 pr_err("failed to fragment tx data packet\n");
164 goto free_exit; 167 goto free_exit;
165 } 168 }
166 } 169 }
@@ -190,7 +193,7 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev,
190 193
191 /* first, make enough room for the already accumulated data */ 194 /* first, make enough room for the already accumulated data */
192 if (skb_cow_head(skb, reassembly_len)) { 195 if (skb_cow_head(skb, reassembly_len)) {
193 nfc_err("error adding room for accumulated rx data"); 196 pr_err("error adding room for accumulated rx data\n");
194 197
195 kfree_skb(skb); 198 kfree_skb(skb);
196 skb = 0; 199 skb = 0;
@@ -227,19 +230,19 @@ void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb)
227{ 230{
228 __u8 pbf = nci_pbf(skb->data); 231 __u8 pbf = nci_pbf(skb->data);
229 232
230 nfc_dbg("entry, len %d", skb->len); 233 pr_debug("len %d\n", skb->len);
231 234
232 nfc_dbg("NCI RX: MT=data, PBF=%d, conn_id=%d, plen=%d", 235 pr_debug("NCI RX: MT=data, PBF=%d, conn_id=%d, plen=%d\n",
233 nci_pbf(skb->data), 236 nci_pbf(skb->data),
234 nci_conn_id(skb->data), 237 nci_conn_id(skb->data),
235 nci_plen(skb->data)); 238 nci_plen(skb->data));
236 239
237 /* strip the nci data header */ 240 /* strip the nci data header */
238 skb_pull(skb, NCI_DATA_HDR_SIZE); 241 skb_pull(skb, NCI_DATA_HDR_SIZE);
239 242
240 if (ndev->target_active_prot == NFC_PROTO_MIFARE) { 243 if (ndev->target_active_prot == NFC_PROTO_MIFARE) {
241 /* frame I/F => remove the status byte */ 244 /* frame I/F => remove the status byte */
242 nfc_dbg("NFC_PROTO_MIFARE => remove the status byte"); 245 pr_debug("NFC_PROTO_MIFARE => remove the status byte\n");
243 skb_trim(skb, (skb->len - 1)); 246 skb_trim(skb, (skb->len - 1));
244 } 247 }
245 248
diff --git a/net/nfc/nci/lib.c b/net/nfc/nci/lib.c
index b19dc2fa90e1..e99adcfb1bcf 100644
--- a/net/nfc/nci/lib.c
+++ b/net/nfc/nci/lib.c
@@ -42,12 +42,9 @@ int nci_to_errno(__u8 code)
42 case NCI_STATUS_REJECTED: 42 case NCI_STATUS_REJECTED:
43 return -EBUSY; 43 return -EBUSY;
44 44
45 case NCI_STATUS_MESSAGE_CORRUPTED: 45 case NCI_STATUS_RF_FRAME_CORRUPTED:
46 return -EBADMSG; 46 return -EBADMSG;
47 47
48 case NCI_STATUS_BUFFER_FULL:
49 return -ENOBUFS;
50
51 case NCI_STATUS_NOT_INITIALIZED: 48 case NCI_STATUS_NOT_INITIALIZED:
52 return -EHOSTDOWN; 49 return -EHOSTDOWN;
53 50
@@ -80,9 +77,6 @@ int nci_to_errno(__u8 code)
80 case NCI_STATUS_NFCEE_TIMEOUT_ERROR: 77 case NCI_STATUS_NFCEE_TIMEOUT_ERROR:
81 return -ETIMEDOUT; 78 return -ETIMEDOUT;
82 79
83 case NCI_STATUS_RF_LINK_LOSS_ERROR:
84 return -ENOLINK;
85
86 case NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED: 80 case NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED:
87 return -EDQUOT; 81 return -EDQUOT;
88 82
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c
index 96633f5cda4f..c36bd4a09abb 100644
--- a/net/nfc/nci/ntf.c
+++ b/net/nfc/nci/ntf.c
@@ -25,6 +25,8 @@
25 * 25 *
26 */ 26 */
27 27
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29
28#include <linux/types.h> 30#include <linux/types.h>
29#include <linux/interrupt.h> 31#include <linux/interrupt.h>
30#include <linux/bitops.h> 32#include <linux/bitops.h>
@@ -43,18 +45,18 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
43 struct nci_core_conn_credit_ntf *ntf = (void *) skb->data; 45 struct nci_core_conn_credit_ntf *ntf = (void *) skb->data;
44 int i; 46 int i;
45 47
46 nfc_dbg("entry, num_entries %d", ntf->num_entries); 48 pr_debug("num_entries %d\n", ntf->num_entries);
47 49
48 if (ntf->num_entries > NCI_MAX_NUM_CONN) 50 if (ntf->num_entries > NCI_MAX_NUM_CONN)
49 ntf->num_entries = NCI_MAX_NUM_CONN; 51 ntf->num_entries = NCI_MAX_NUM_CONN;
50 52
51 /* update the credits */ 53 /* update the credits */
52 for (i = 0; i < ntf->num_entries; i++) { 54 for (i = 0; i < ntf->num_entries; i++) {
53 nfc_dbg("entry[%d]: conn_id %d, credits %d", i, 55 pr_debug("entry[%d]: conn_id %d, credits %d\n",
54 ntf->conn_entries[i].conn_id, 56 i, ntf->conn_entries[i].conn_id,
55 ntf->conn_entries[i].credits); 57 ntf->conn_entries[i].credits);
56 58
57 if (ntf->conn_entries[i].conn_id == ndev->conn_id) { 59 if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) {
58 /* found static rf connection */ 60 /* found static rf connection */
59 atomic_add(ntf->conn_entries[i].credits, 61 atomic_add(ntf->conn_entries[i].credits,
60 &ndev->credits_cnt); 62 &ndev->credits_cnt);
@@ -66,31 +68,20 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
66 queue_work(ndev->tx_wq, &ndev->tx_work); 68 queue_work(ndev->tx_wq, &ndev->tx_work);
67} 69}
68 70
69static void nci_rf_field_info_ntf_packet(struct nci_dev *ndev, 71static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
70 struct sk_buff *skb) 72 struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
71{
72 struct nci_rf_field_info_ntf *ntf = (void *) skb->data;
73
74 nfc_dbg("entry, rf_field_status %d", ntf->rf_field_status);
75}
76
77static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev,
78 struct nci_rf_activate_ntf *ntf, __u8 *data)
79{ 73{
80 struct rf_tech_specific_params_nfca_poll *nfca_poll; 74 struct rf_tech_specific_params_nfca_poll *nfca_poll;
81 struct activation_params_nfca_poll_iso_dep *nfca_poll_iso_dep;
82 75
83 nfca_poll = &ntf->rf_tech_specific_params.nfca_poll; 76 nfca_poll = &ntf->rf_tech_specific_params.nfca_poll;
84 nfca_poll_iso_dep = &ntf->activation_params.nfca_poll_iso_dep;
85 77
86 nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); 78 nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data));
87 data += 2; 79 data += 2;
88 80
89 nfca_poll->nfcid1_len = *data++; 81 nfca_poll->nfcid1_len = *data++;
90 82
91 nfc_dbg("sens_res 0x%x, nfcid1_len %d", 83 pr_debug("sens_res 0x%x, nfcid1_len %d\n",
92 nfca_poll->sens_res, 84 nfca_poll->sens_res, nfca_poll->nfcid1_len);
93 nfca_poll->nfcid1_len);
94 85
95 memcpy(nfca_poll->nfcid1, data, nfca_poll->nfcid1_len); 86 memcpy(nfca_poll->nfcid1, data, nfca_poll->nfcid1_len);
96 data += nfca_poll->nfcid1_len; 87 data += nfca_poll->nfcid1_len;
@@ -100,32 +91,32 @@ static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev,
100 if (nfca_poll->sel_res_len != 0) 91 if (nfca_poll->sel_res_len != 0)
101 nfca_poll->sel_res = *data++; 92 nfca_poll->sel_res = *data++;
102 93
103 ntf->rf_interface_type = *data++; 94 pr_debug("sel_res_len %d, sel_res 0x%x\n",
104 ntf->activation_params_len = *data++; 95 nfca_poll->sel_res_len,
96 nfca_poll->sel_res);
105 97
106 nfc_dbg("sel_res_len %d, sel_res 0x%x, rf_interface_type %d, activation_params_len %d", 98 return data;
107 nfca_poll->sel_res_len, 99}
108 nfca_poll->sel_res,
109 ntf->rf_interface_type,
110 ntf->activation_params_len);
111 100
112 switch (ntf->rf_interface_type) { 101static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
113 case NCI_RF_INTERFACE_ISO_DEP: 102 struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
114 nfca_poll_iso_dep->rats_res_len = *data++; 103{
115 if (nfca_poll_iso_dep->rats_res_len > 0) { 104 struct activation_params_nfca_poll_iso_dep *nfca_poll;
116 memcpy(nfca_poll_iso_dep->rats_res, 105
106 switch (ntf->activation_rf_tech_and_mode) {
107 case NCI_NFC_A_PASSIVE_POLL_MODE:
108 nfca_poll = &ntf->activation_params.nfca_poll_iso_dep;
109 nfca_poll->rats_res_len = *data++;
110 if (nfca_poll->rats_res_len > 0) {
111 memcpy(nfca_poll->rats_res,
117 data, 112 data,
118 nfca_poll_iso_dep->rats_res_len); 113 nfca_poll->rats_res_len);
119 } 114 }
120 break; 115 break;
121 116
122 case NCI_RF_INTERFACE_FRAME:
123 /* no activation params */
124 break;
125
126 default: 117 default:
127 nfc_err("unsupported rf_interface_type 0x%x", 118 pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
128 ntf->rf_interface_type); 119 ntf->activation_rf_tech_and_mode);
129 return -EPROTO; 120 return -EPROTO;
130 } 121 }
131 122
@@ -133,7 +124,7 @@ static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev,
133} 124}
134 125
135static void nci_target_found(struct nci_dev *ndev, 126static void nci_target_found(struct nci_dev *ndev,
136 struct nci_rf_activate_ntf *ntf) 127 struct nci_rf_intf_activated_ntf *ntf)
137{ 128{
138 struct nfc_target nfc_tgt; 129 struct nfc_target nfc_tgt;
139 130
@@ -141,66 +132,105 @@ static void nci_target_found(struct nci_dev *ndev,
141 nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK; 132 nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK;
142 else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */ 133 else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */
143 nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK; 134 nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK;
135 else
136 nfc_tgt.supported_protocols = 0;
144 137
145 nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res; 138 nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res;
146 nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res; 139 nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res;
147 140
148 if (!(nfc_tgt.supported_protocols & ndev->poll_prots)) { 141 if (!(nfc_tgt.supported_protocols & ndev->poll_prots)) {
149 nfc_dbg("the target found does not have the desired protocol"); 142 pr_debug("the target found does not have the desired protocol\n");
150 return; 143 return;
151 } 144 }
152 145
153 nfc_dbg("new target found, supported_protocols 0x%x", 146 pr_debug("new target found, supported_protocols 0x%x\n",
154 nfc_tgt.supported_protocols); 147 nfc_tgt.supported_protocols);
155 148
156 ndev->target_available_prots = nfc_tgt.supported_protocols; 149 ndev->target_available_prots = nfc_tgt.supported_protocols;
157 150
158 nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1); 151 nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1);
159} 152}
160 153
161static void nci_rf_activate_ntf_packet(struct nci_dev *ndev, 154static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
162 struct sk_buff *skb) 155 struct sk_buff *skb)
163{ 156{
164 struct nci_rf_activate_ntf ntf; 157 struct nci_rf_intf_activated_ntf ntf;
165 __u8 *data = skb->data; 158 __u8 *data = skb->data;
166 int rc = -1; 159 int err = 0;
167 160
168 clear_bit(NCI_DISCOVERY, &ndev->flags); 161 clear_bit(NCI_DISCOVERY, &ndev->flags);
169 set_bit(NCI_POLL_ACTIVE, &ndev->flags); 162 set_bit(NCI_POLL_ACTIVE, &ndev->flags);
170 163
171 ntf.target_handle = *data++; 164 ntf.rf_discovery_id = *data++;
165 ntf.rf_interface_type = *data++;
172 ntf.rf_protocol = *data++; 166 ntf.rf_protocol = *data++;
173 ntf.rf_tech_and_mode = *data++; 167 ntf.activation_rf_tech_and_mode = *data++;
174 ntf.rf_tech_specific_params_len = *data++; 168 ntf.rf_tech_specific_params_len = *data++;
175 169
176 nfc_dbg("target_handle %d, rf_protocol 0x%x, rf_tech_and_mode 0x%x, rf_tech_specific_params_len %d", 170 pr_debug("rf_discovery_id %d\n", ntf.rf_discovery_id);
177 ntf.target_handle, 171 pr_debug("rf_interface_type 0x%x\n", ntf.rf_interface_type);
178 ntf.rf_protocol, 172 pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol);
179 ntf.rf_tech_and_mode, 173 pr_debug("activation_rf_tech_and_mode 0x%x\n",
180 ntf.rf_tech_specific_params_len); 174 ntf.activation_rf_tech_and_mode);
181 175 pr_debug("rf_tech_specific_params_len %d\n",
182 switch (ntf.rf_tech_and_mode) { 176 ntf.rf_tech_specific_params_len);
183 case NCI_NFC_A_PASSIVE_POLL_MODE: 177
184 rc = nci_rf_activate_nfca_passive_poll(ndev, &ntf, 178 if (ntf.rf_tech_specific_params_len > 0) {
185 data); 179 switch (ntf.activation_rf_tech_and_mode) {
186 break; 180 case NCI_NFC_A_PASSIVE_POLL_MODE:
181 data = nci_extract_rf_params_nfca_passive_poll(ndev,
182 &ntf, data);
183 break;
184
185 default:
186 pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
187 ntf.activation_rf_tech_and_mode);
188 return;
189 }
190 }
187 191
188 default: 192 ntf.data_exch_rf_tech_and_mode = *data++;
189 nfc_err("unsupported rf_tech_and_mode 0x%x", 193 ntf.data_exch_tx_bit_rate = *data++;
190 ntf.rf_tech_and_mode); 194 ntf.data_exch_rx_bit_rate = *data++;
191 return; 195 ntf.activation_params_len = *data++;
196
197 pr_debug("data_exch_rf_tech_and_mode 0x%x\n",
198 ntf.data_exch_rf_tech_and_mode);
199 pr_debug("data_exch_tx_bit_rate 0x%x\n",
200 ntf.data_exch_tx_bit_rate);
201 pr_debug("data_exch_rx_bit_rate 0x%x\n",
202 ntf.data_exch_rx_bit_rate);
203 pr_debug("activation_params_len %d\n",
204 ntf.activation_params_len);
205
206 if (ntf.activation_params_len > 0) {
207 switch (ntf.rf_interface_type) {
208 case NCI_RF_INTERFACE_ISO_DEP:
209 err = nci_extract_activation_params_iso_dep(ndev,
210 &ntf, data);
211 break;
212
213 case NCI_RF_INTERFACE_FRAME:
214 /* no activation params */
215 break;
216
217 default:
218 pr_err("unsupported rf_interface_type 0x%x\n",
219 ntf.rf_interface_type);
220 return;
221 }
192 } 222 }
193 223
194 if (!rc) 224 if (!err)
195 nci_target_found(ndev, &ntf); 225 nci_target_found(ndev, &ntf);
196} 226}
197 227
198static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, 228static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
199 struct sk_buff *skb) 229 struct sk_buff *skb)
200{ 230{
201 __u8 type = skb->data[0]; 231 struct nci_rf_deactivate_ntf *ntf = (void *) skb->data;
202 232
203 nfc_dbg("entry, type 0x%x", type); 233 pr_debug("entry, type 0x%x, reason 0x%x\n", ntf->type, ntf->reason);
204 234
205 clear_bit(NCI_POLL_ACTIVE, &ndev->flags); 235 clear_bit(NCI_POLL_ACTIVE, &ndev->flags);
206 ndev->target_active_prot = 0; 236 ndev->target_active_prot = 0;
@@ -214,6 +244,9 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
214 ndev->rx_data_reassembly = 0; 244 ndev->rx_data_reassembly = 0;
215 } 245 }
216 246
247 /* set the available credits to initial value */
248 atomic_set(&ndev->credits_cnt, ndev->initial_num_credits);
249
217 /* complete the data exchange transaction, if exists */ 250 /* complete the data exchange transaction, if exists */
218 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) 251 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags))
219 nci_data_exchange_complete(ndev, NULL, -EIO); 252 nci_data_exchange_complete(ndev, NULL, -EIO);
@@ -223,11 +256,11 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
223{ 256{
224 __u16 ntf_opcode = nci_opcode(skb->data); 257 __u16 ntf_opcode = nci_opcode(skb->data);
225 258
226 nfc_dbg("NCI RX: MT=ntf, PBF=%d, GID=0x%x, OID=0x%x, plen=%d", 259 pr_debug("NCI RX: MT=ntf, PBF=%d, GID=0x%x, OID=0x%x, plen=%d\n",
227 nci_pbf(skb->data), 260 nci_pbf(skb->data),
228 nci_opcode_gid(ntf_opcode), 261 nci_opcode_gid(ntf_opcode),
229 nci_opcode_oid(ntf_opcode), 262 nci_opcode_oid(ntf_opcode),
230 nci_plen(skb->data)); 263 nci_plen(skb->data));
231 264
232 /* strip the nci control header */ 265 /* strip the nci control header */
233 skb_pull(skb, NCI_CTRL_HDR_SIZE); 266 skb_pull(skb, NCI_CTRL_HDR_SIZE);
@@ -237,12 +270,8 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
237 nci_core_conn_credits_ntf_packet(ndev, skb); 270 nci_core_conn_credits_ntf_packet(ndev, skb);
238 break; 271 break;
239 272
240 case NCI_OP_RF_FIELD_INFO_NTF: 273 case NCI_OP_RF_INTF_ACTIVATED_NTF:
241 nci_rf_field_info_ntf_packet(ndev, skb); 274 nci_rf_intf_activated_ntf_packet(ndev, skb);
242 break;
243
244 case NCI_OP_RF_ACTIVATE_NTF:
245 nci_rf_activate_ntf_packet(ndev, skb);
246 break; 275 break;
247 276
248 case NCI_OP_RF_DEACTIVATE_NTF: 277 case NCI_OP_RF_DEACTIVATE_NTF:
@@ -250,7 +279,7 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
250 break; 279 break;
251 280
252 default: 281 default:
253 nfc_err("unknown ntf opcode 0x%x", ntf_opcode); 282 pr_err("unknown ntf opcode 0x%x\n", ntf_opcode);
254 break; 283 break;
255 } 284 }
256 285
diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c
index 0403d4cd0917..ca611c52aaaa 100644
--- a/net/nfc/nci/rsp.c
+++ b/net/nfc/nci/rsp.c
@@ -25,6 +25,8 @@
25 * 25 *
26 */ 26 */
27 27
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29
28#include <linux/types.h> 30#include <linux/types.h>
29#include <linux/interrupt.h> 31#include <linux/interrupt.h>
30#include <linux/bitops.h> 32#include <linux/bitops.h>
@@ -40,12 +42,13 @@ static void nci_core_reset_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
40{ 42{
41 struct nci_core_reset_rsp *rsp = (void *) skb->data; 43 struct nci_core_reset_rsp *rsp = (void *) skb->data;
42 44
43 nfc_dbg("entry, status 0x%x", rsp->status); 45 pr_debug("status 0x%x\n", rsp->status);
44 46
45 if (rsp->status == NCI_STATUS_OK) 47 if (rsp->status == NCI_STATUS_OK) {
46 ndev->nci_ver = rsp->nci_ver; 48 ndev->nci_ver = rsp->nci_ver;
47 49 pr_debug("nci_ver 0x%x, config_status 0x%x\n",
48 nfc_dbg("nci_ver 0x%x", ndev->nci_ver); 50 rsp->nci_ver, rsp->config_status);
51 }
49 52
50 nci_req_complete(ndev, rsp->status); 53 nci_req_complete(ndev, rsp->status);
51} 54}
@@ -55,16 +58,16 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
55 struct nci_core_init_rsp_1 *rsp_1 = (void *) skb->data; 58 struct nci_core_init_rsp_1 *rsp_1 = (void *) skb->data;
56 struct nci_core_init_rsp_2 *rsp_2; 59 struct nci_core_init_rsp_2 *rsp_2;
57 60
58 nfc_dbg("entry, status 0x%x", rsp_1->status); 61 pr_debug("status 0x%x\n", rsp_1->status);
59 62
60 if (rsp_1->status != NCI_STATUS_OK) 63 if (rsp_1->status != NCI_STATUS_OK)
61 return; 64 goto exit;
62 65
63 ndev->nfcc_features = __le32_to_cpu(rsp_1->nfcc_features); 66 ndev->nfcc_features = __le32_to_cpu(rsp_1->nfcc_features);
64 ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces; 67 ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces;
65 68
66 if (ndev->num_supported_rf_interfaces > 69 if (ndev->num_supported_rf_interfaces >
67 NCI_MAX_SUPPORTED_RF_INTERFACES) { 70 NCI_MAX_SUPPORTED_RF_INTERFACES) {
68 ndev->num_supported_rf_interfaces = 71 ndev->num_supported_rf_interfaces =
69 NCI_MAX_SUPPORTED_RF_INTERFACES; 72 NCI_MAX_SUPPORTED_RF_INTERFACES;
70 } 73 }
@@ -73,68 +76,58 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
73 rsp_1->supported_rf_interfaces, 76 rsp_1->supported_rf_interfaces,
74 ndev->num_supported_rf_interfaces); 77 ndev->num_supported_rf_interfaces);
75 78
76 rsp_2 = (void *) (skb->data + 6 + ndev->num_supported_rf_interfaces); 79 rsp_2 = (void *) (skb->data + 6 + rsp_1->num_supported_rf_interfaces);
77 80
78 ndev->max_logical_connections = 81 ndev->max_logical_connections =
79 rsp_2->max_logical_connections; 82 rsp_2->max_logical_connections;
80 ndev->max_routing_table_size = 83 ndev->max_routing_table_size =
81 __le16_to_cpu(rsp_2->max_routing_table_size); 84 __le16_to_cpu(rsp_2->max_routing_table_size);
82 ndev->max_control_packet_payload_length = 85 ndev->max_ctrl_pkt_payload_len =
83 rsp_2->max_control_packet_payload_length; 86 rsp_2->max_ctrl_pkt_payload_len;
84 ndev->rf_sending_buffer_size = 87 ndev->max_size_for_large_params =
85 __le16_to_cpu(rsp_2->rf_sending_buffer_size); 88 __le16_to_cpu(rsp_2->max_size_for_large_params);
86 ndev->rf_receiving_buffer_size = 89 ndev->max_data_pkt_payload_size =
87 __le16_to_cpu(rsp_2->rf_receiving_buffer_size); 90 rsp_2->max_data_pkt_payload_size;
88 ndev->manufacturer_id = 91 ndev->initial_num_credits =
89 __le16_to_cpu(rsp_2->manufacturer_id); 92 rsp_2->initial_num_credits;
90 93 ndev->manufact_id =
91 nfc_dbg("nfcc_features 0x%x", 94 rsp_2->manufact_id;
92 ndev->nfcc_features); 95 ndev->manufact_specific_info =
93 nfc_dbg("num_supported_rf_interfaces %d", 96 __le32_to_cpu(rsp_2->manufact_specific_info);
94 ndev->num_supported_rf_interfaces);
95 nfc_dbg("supported_rf_interfaces[0] 0x%x",
96 ndev->supported_rf_interfaces[0]);
97 nfc_dbg("supported_rf_interfaces[1] 0x%x",
98 ndev->supported_rf_interfaces[1]);
99 nfc_dbg("supported_rf_interfaces[2] 0x%x",
100 ndev->supported_rf_interfaces[2]);
101 nfc_dbg("supported_rf_interfaces[3] 0x%x",
102 ndev->supported_rf_interfaces[3]);
103 nfc_dbg("max_logical_connections %d",
104 ndev->max_logical_connections);
105 nfc_dbg("max_routing_table_size %d",
106 ndev->max_routing_table_size);
107 nfc_dbg("max_control_packet_payload_length %d",
108 ndev->max_control_packet_payload_length);
109 nfc_dbg("rf_sending_buffer_size %d",
110 ndev->rf_sending_buffer_size);
111 nfc_dbg("rf_receiving_buffer_size %d",
112 ndev->rf_receiving_buffer_size);
113 nfc_dbg("manufacturer_id 0x%x",
114 ndev->manufacturer_id);
115
116 nci_req_complete(ndev, rsp_1->status);
117}
118
119static void nci_core_conn_create_rsp_packet(struct nci_dev *ndev,
120 struct sk_buff *skb)
121{
122 struct nci_core_conn_create_rsp *rsp = (void *) skb->data;
123
124 nfc_dbg("entry, status 0x%x", rsp->status);
125
126 if (rsp->status != NCI_STATUS_OK)
127 return;
128
129 ndev->max_pkt_payload_size = rsp->max_pkt_payload_size;
130 ndev->initial_num_credits = rsp->initial_num_credits;
131 ndev->conn_id = rsp->conn_id;
132 97
133 atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); 98 atomic_set(&ndev->credits_cnt, ndev->initial_num_credits);
134 99
135 nfc_dbg("max_pkt_payload_size %d", ndev->max_pkt_payload_size); 100 pr_debug("nfcc_features 0x%x\n",
136 nfc_dbg("initial_num_credits %d", ndev->initial_num_credits); 101 ndev->nfcc_features);
137 nfc_dbg("conn_id %d", ndev->conn_id); 102 pr_debug("num_supported_rf_interfaces %d\n",
103 ndev->num_supported_rf_interfaces);
104 pr_debug("supported_rf_interfaces[0] 0x%x\n",
105 ndev->supported_rf_interfaces[0]);
106 pr_debug("supported_rf_interfaces[1] 0x%x\n",
107 ndev->supported_rf_interfaces[1]);
108 pr_debug("supported_rf_interfaces[2] 0x%x\n",
109 ndev->supported_rf_interfaces[2]);
110 pr_debug("supported_rf_interfaces[3] 0x%x\n",
111 ndev->supported_rf_interfaces[3]);
112 pr_debug("max_logical_connections %d\n",
113 ndev->max_logical_connections);
114 pr_debug("max_routing_table_size %d\n",
115 ndev->max_routing_table_size);
116 pr_debug("max_ctrl_pkt_payload_len %d\n",
117 ndev->max_ctrl_pkt_payload_len);
118 pr_debug("max_size_for_large_params %d\n",
119 ndev->max_size_for_large_params);
120 pr_debug("max_data_pkt_payload_size %d\n",
121 ndev->max_data_pkt_payload_size);
122 pr_debug("initial_num_credits %d\n",
123 ndev->initial_num_credits);
124 pr_debug("manufact_id 0x%x\n",
125 ndev->manufact_id);
126 pr_debug("manufact_specific_info 0x%x\n",
127 ndev->manufact_specific_info);
128
129exit:
130 nci_req_complete(ndev, rsp_1->status);
138} 131}
139 132
140static void nci_rf_disc_map_rsp_packet(struct nci_dev *ndev, 133static void nci_rf_disc_map_rsp_packet(struct nci_dev *ndev,
@@ -142,7 +135,7 @@ static void nci_rf_disc_map_rsp_packet(struct nci_dev *ndev,
142{ 135{
143 __u8 status = skb->data[0]; 136 __u8 status = skb->data[0];
144 137
145 nfc_dbg("entry, status 0x%x", status); 138 pr_debug("status 0x%x\n", status);
146 139
147 nci_req_complete(ndev, status); 140 nci_req_complete(ndev, status);
148} 141}
@@ -151,7 +144,7 @@ static void nci_rf_disc_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
151{ 144{
152 __u8 status = skb->data[0]; 145 __u8 status = skb->data[0];
153 146
154 nfc_dbg("entry, status 0x%x", status); 147 pr_debug("status 0x%x\n", status);
155 148
156 if (status == NCI_STATUS_OK) 149 if (status == NCI_STATUS_OK)
157 set_bit(NCI_DISCOVERY, &ndev->flags); 150 set_bit(NCI_DISCOVERY, &ndev->flags);
@@ -164,7 +157,7 @@ static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev,
164{ 157{
165 __u8 status = skb->data[0]; 158 __u8 status = skb->data[0];
166 159
167 nfc_dbg("entry, status 0x%x", status); 160 pr_debug("status 0x%x\n", status);
168 161
169 clear_bit(NCI_DISCOVERY, &ndev->flags); 162 clear_bit(NCI_DISCOVERY, &ndev->flags);
170 163
@@ -178,11 +171,11 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
178 /* we got a rsp, stop the cmd timer */ 171 /* we got a rsp, stop the cmd timer */
179 del_timer(&ndev->cmd_timer); 172 del_timer(&ndev->cmd_timer);
180 173
181 nfc_dbg("NCI RX: MT=rsp, PBF=%d, GID=0x%x, OID=0x%x, plen=%d", 174 pr_debug("NCI RX: MT=rsp, PBF=%d, GID=0x%x, OID=0x%x, plen=%d\n",
182 nci_pbf(skb->data), 175 nci_pbf(skb->data),
183 nci_opcode_gid(rsp_opcode), 176 nci_opcode_gid(rsp_opcode),
184 nci_opcode_oid(rsp_opcode), 177 nci_opcode_oid(rsp_opcode),
185 nci_plen(skb->data)); 178 nci_plen(skb->data));
186 179
187 /* strip the nci control header */ 180 /* strip the nci control header */
188 skb_pull(skb, NCI_CTRL_HDR_SIZE); 181 skb_pull(skb, NCI_CTRL_HDR_SIZE);
@@ -196,10 +189,6 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
196 nci_core_init_rsp_packet(ndev, skb); 189 nci_core_init_rsp_packet(ndev, skb);
197 break; 190 break;
198 191
199 case NCI_OP_CORE_CONN_CREATE_RSP:
200 nci_core_conn_create_rsp_packet(ndev, skb);
201 break;
202
203 case NCI_OP_RF_DISCOVER_MAP_RSP: 192 case NCI_OP_RF_DISCOVER_MAP_RSP:
204 nci_rf_disc_map_rsp_packet(ndev, skb); 193 nci_rf_disc_map_rsp_packet(ndev, skb);
205 break; 194 break;
@@ -213,7 +202,7 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
213 break; 202 break;
214 203
215 default: 204 default:
216 nfc_err("unknown rsp opcode 0x%x", rsp_opcode); 205 pr_err("unknown rsp opcode 0x%x\n", rsp_opcode);
217 break; 206 break;
218 } 207 }
219 208