NFC: Cache the core NFC active target pointer instead of its index
[deliverable/linux.git] / net / nfc / hci / core.c
index 86fd00d5a0992ace69730780c526fc8a9a17be2c..545c19f17536f218af6b709e12558d4384011a18 100644 (file)
@@ -520,50 +520,26 @@ static void hci_stop_poll(struct nfc_dev *nfc_dev)
        }
 }
 
-static struct nfc_target *hci_find_target(struct nfc_hci_dev *hdev,
-                                         u32 target_idx)
+static int hci_activate_target(struct nfc_dev *nfc_dev,
+                              struct nfc_target *target, u32 protocol)
 {
-       int i;
-       if (hdev->poll_started == false || hdev->targets == NULL)
-               return NULL;
-
-       for (i = 0; i < hdev->target_count; i++) {
-               if (hdev->targets[i].idx == target_idx)
-                       return &hdev->targets[i];
-       }
-
-       return NULL;
-}
-
-static int hci_activate_target(struct nfc_dev *nfc_dev, u32 target_idx,
-                              u32 protocol)
-{
-       struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
-
-       if (hci_find_target(hdev, target_idx) == NULL)
-               return -ENOMEDIUM;
-
        return 0;
 }
 
-static void hci_deactivate_target(struct nfc_dev *nfc_dev, u32 target_idx)
+static void hci_deactivate_target(struct nfc_dev *nfc_dev,
+                                 struct nfc_target *target)
 {
 }
 
-static int hci_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx,
+static int hci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target,
                             struct sk_buff *skb, data_exchange_cb_t cb,
                             void *cb_context)
 {
        struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
        int r;
-       struct nfc_target *target;
        struct sk_buff *res_skb = NULL;
 
-       pr_debug("target_idx=%d\n", target_idx);
-
-       target = hci_find_target(hdev, target_idx);
-       if (target == NULL)
-               return -ENOMEDIUM;
+       pr_debug("target_idx=%d\n", target->idx);
 
        switch (target->hci_reader_gate) {
        case NFC_HCI_RF_READER_A_GATE:
This page took 0.024963 seconds and 5 git commands to generate.