NFC: Add HCI/SHDLC support to let driver check for tag presence
authorEric Lapuyade <eric.lapuyade@intel.com>
Mon, 7 May 2012 10:31:16 +0000 (12:31 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 15 May 2012 21:28:00 +0000 (17:28 -0400)
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>
include/net/nfc/hci.h
include/net/nfc/shdlc.h
net/nfc/hci/core.c
net/nfc/hci/shdlc.c

index 95fc0c27578e184844e75574da2a42bd9ef0005f..ae042008571e3f3245db31421fade4e6d2859441 100644 (file)
@@ -39,6 +39,8 @@ struct nfc_hci_ops {
        int (*data_exchange) (struct nfc_hci_dev *hdev,
                              struct nfc_target *target,
                              struct sk_buff *skb, struct sk_buff **res_skb);
+       int (*check_presence)(struct nfc_hci_dev *hdev,
+                             struct nfc_target *target);
 };
 
 #define NFC_HCI_MAX_CUSTOM_GATES       15
index 1071987d040849d344aba60dd5867146c4d48641..ab06afd462daf4eb5fb3270cc4ba096ece3f41f9 100644 (file)
@@ -35,6 +35,8 @@ struct nfc_shdlc_ops {
        int (*data_exchange) (struct nfc_shdlc *shdlc,
                              struct nfc_target *target,
                              struct sk_buff *skb, struct sk_buff **res_skb);
+       int (*check_presence)(struct nfc_shdlc *shdlc,
+                             struct nfc_target *target);
 };
 
 enum shdlc_state {
index ef5cd5c9e3fb082fded801b4627ae48af33aca07..f7e4f5ae4559afb007e9e7311f698de19a1abae5 100644 (file)
@@ -574,6 +574,17 @@ static int hci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target,
        return 0;
 }
 
+static int hci_check_presence(struct nfc_dev *nfc_dev,
+                             struct nfc_target *target)
+{
+       struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
+
+       if (hdev->ops->check_presence)
+               return hdev->ops->check_presence(hdev, target);
+
+       return 0;
+}
+
 struct nfc_ops hci_nfc_ops = {
        .dev_up = hci_dev_up,
        .dev_down = hci_dev_down,
@@ -582,6 +593,7 @@ struct nfc_ops hci_nfc_ops = {
        .activate_target = hci_activate_target,
        .deactivate_target = hci_deactivate_target,
        .data_exchange = hci_data_exchange,
+       .check_presence = hci_check_presence,
 };
 
 struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops,
index 923bdf7c26d6da6ac5db34b6a2800cec5d2e5125..5665dc6d893a0800048abeba14d996c4f82b6d98 100644 (file)
@@ -816,6 +816,17 @@ static int nfc_shdlc_data_exchange(struct nfc_hci_dev *hdev,
        return -EPERM;
 }
 
+static int nfc_shdlc_check_presence(struct nfc_hci_dev *hdev,
+                                   struct nfc_target *target)
+{
+       struct nfc_shdlc *shdlc = nfc_hci_get_clientdata(hdev);
+
+       if (shdlc->ops->check_presence)
+               return shdlc->ops->check_presence(shdlc, target);
+
+       return 0;
+}
+
 static struct nfc_hci_ops shdlc_ops = {
        .open = nfc_shdlc_open,
        .close = nfc_shdlc_close,
@@ -825,6 +836,7 @@ static struct nfc_hci_ops shdlc_ops = {
        .target_from_gate = nfc_shdlc_target_from_gate,
        .complete_target_discovered = nfc_shdlc_complete_target_discovered,
        .data_exchange = nfc_shdlc_data_exchange,
+       .check_presence = nfc_shdlc_check_presence,
 };
 
 struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops,