aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/hci
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@intel.com>2012-05-07 06:31:13 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-05-15 17:27:59 -0400
commit900994332675f84a9fbbb33ff089474614c7f2fe (patch)
tree6b9b6f7b50217a30e72848466865e521ee64d048 /net/nfc/hci
parent536acc085c641ff8ba46c2c0e97b5e137cbc22d6 (diff)
NFC: Cache the core NFC active target pointer instead of its index
The NFC Core now caches the active nfc target pointer, thereby avoiding the need to lookup the target table for each invocation of a driver ops. Consequently, pn533, HCI and NCI now directly receive an nfc_target pointer instead of a target index. Cc: Ilan Elias <ilane@ti.com> Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/nfc/hci')
-rw-r--r--net/nfc/hci/core.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 86fd00d5a099..545c19f17536 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -520,50 +520,26 @@ static void hci_stop_poll(struct nfc_dev *nfc_dev)
520 } 520 }
521} 521}
522 522
523static struct nfc_target *hci_find_target(struct nfc_hci_dev *hdev, 523static int hci_activate_target(struct nfc_dev *nfc_dev,
524 u32 target_idx) 524 struct nfc_target *target, u32 protocol)
525{ 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}
537
538static int hci_activate_target(struct nfc_dev *nfc_dev, u32 target_idx,
539 u32 protocol)
540{
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; 526 return 0;
547} 527}
548 528
549static void hci_deactivate_target(struct nfc_dev *nfc_dev, u32 target_idx) 529static void hci_deactivate_target(struct nfc_dev *nfc_dev,
530 struct nfc_target *target)
550{ 531{
551} 532}
552 533
553static int hci_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx, 534static int hci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target,
554 struct sk_buff *skb, data_exchange_cb_t cb, 535 struct sk_buff *skb, data_exchange_cb_t cb,
555 void *cb_context) 536 void *cb_context)
556{ 537{
557 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); 538 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
558 int r; 539 int r;
559 struct nfc_target *target;
560 struct sk_buff *res_skb = NULL; 540 struct sk_buff *res_skb = NULL;
561 541
562 pr_debug("target_idx=%d\n", target_idx); 542 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 543
568 switch (target->hci_reader_gate) { 544 switch (target->hci_reader_gate) {
569 case NFC_HCI_RF_READER_A_GATE: 545 case NFC_HCI_RF_READER_A_GATE: