aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@intel.com>2012-05-07 06:31:16 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-05-15 17:28:00 -0400
commit1676f75159c8091e865c33b61ad4934dfd3b7821 (patch)
treebabd0f9912f05a2608c4fab5084345d408c67169
parentd4ccb132801aeeb2cfd18c4b4b7fa0043ab37f80 (diff)
NFC: Add HCI/SHDLC support to let driver check for tag presence
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>
-rw-r--r--include/net/nfc/hci.h2
-rw-r--r--include/net/nfc/shdlc.h2
-rw-r--r--net/nfc/hci/core.c12
-rw-r--r--net/nfc/hci/shdlc.c12
4 files changed, 28 insertions, 0 deletions
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h
index 95fc0c27578e..ae042008571e 100644
--- a/include/net/nfc/hci.h
+++ b/include/net/nfc/hci.h
@@ -39,6 +39,8 @@ struct nfc_hci_ops {
39 int (*data_exchange) (struct nfc_hci_dev *hdev, 39 int (*data_exchange) (struct nfc_hci_dev *hdev,
40 struct nfc_target *target, 40 struct nfc_target *target,
41 struct sk_buff *skb, struct sk_buff **res_skb); 41 struct sk_buff *skb, struct sk_buff **res_skb);
42 int (*check_presence)(struct nfc_hci_dev *hdev,
43 struct nfc_target *target);
42}; 44};
43 45
44#define NFC_HCI_MAX_CUSTOM_GATES 15 46#define NFC_HCI_MAX_CUSTOM_GATES 15
diff --git a/include/net/nfc/shdlc.h b/include/net/nfc/shdlc.h
index 1071987d0408..ab06afd462da 100644
--- a/include/net/nfc/shdlc.h
+++ b/include/net/nfc/shdlc.h
@@ -35,6 +35,8 @@ struct nfc_shdlc_ops {
35 int (*data_exchange) (struct nfc_shdlc *shdlc, 35 int (*data_exchange) (struct nfc_shdlc *shdlc,
36 struct nfc_target *target, 36 struct nfc_target *target,
37 struct sk_buff *skb, struct sk_buff **res_skb); 37 struct sk_buff *skb, struct sk_buff **res_skb);
38 int (*check_presence)(struct nfc_shdlc *shdlc,
39 struct nfc_target *target);
38}; 40};
39 41
40enum shdlc_state { 42enum shdlc_state {
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index ef5cd5c9e3fb..f7e4f5ae4559 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -574,6 +574,17 @@ static int hci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target,
574 return 0; 574 return 0;
575} 575}
576 576
577static int hci_check_presence(struct nfc_dev *nfc_dev,
578 struct nfc_target *target)
579{
580 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
581
582 if (hdev->ops->check_presence)
583 return hdev->ops->check_presence(hdev, target);
584
585 return 0;
586}
587
577struct nfc_ops hci_nfc_ops = { 588struct nfc_ops hci_nfc_ops = {
578 .dev_up = hci_dev_up, 589 .dev_up = hci_dev_up,
579 .dev_down = hci_dev_down, 590 .dev_down = hci_dev_down,
@@ -582,6 +593,7 @@ struct nfc_ops hci_nfc_ops = {
582 .activate_target = hci_activate_target, 593 .activate_target = hci_activate_target,
583 .deactivate_target = hci_deactivate_target, 594 .deactivate_target = hci_deactivate_target,
584 .data_exchange = hci_data_exchange, 595 .data_exchange = hci_data_exchange,
596 .check_presence = hci_check_presence,
585}; 597};
586 598
587struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, 599struct 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
819static 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
819static struct nfc_hci_ops shdlc_ops = { 830static 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
830struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops, 842struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops,