aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/nfc/hci.h5
-rw-r--r--include/net/nfc/nfc.h7
-rw-r--r--net/nfc/core.c7
-rw-r--r--net/nfc/hci/core.c33
-rw-r--r--net/nfc/nci/core.c18
5 files changed, 66 insertions, 4 deletions
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h
index eca8846a63d6..0af851c3b038 100644
--- a/include/net/nfc/hci.h
+++ b/include/net/nfc/hci.h
@@ -59,9 +59,10 @@ struct nfc_hci_ops {
59 struct nfc_target *target); 59 struct nfc_target *target);
60 int (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event, 60 int (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event,
61 struct sk_buff *skb); 61 struct sk_buff *skb);
62 int (*enable_se)(struct nfc_dev *dev, u32 secure_element);
63 int (*disable_se)(struct nfc_dev *dev, u32 secure_element);
64 int (*fw_upload)(struct nfc_hci_dev *hdev, const char *firmware_name); 62 int (*fw_upload)(struct nfc_hci_dev *hdev, const char *firmware_name);
63 int (*discover_se)(struct nfc_hci_dev *dev);
64 int (*enable_se)(struct nfc_hci_dev *dev, u32 se_idx);
65 int (*disable_se)(struct nfc_hci_dev *dev, u32 se_idx);
65}; 66};
66 67
67/* Pipes */ 68/* Pipes */
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index 9900c0f5d6bd..5187ec70b66a 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -68,9 +68,12 @@ struct nfc_ops {
68 void *cb_context); 68 void *cb_context);
69 int (*tm_send)(struct nfc_dev *dev, struct sk_buff *skb); 69 int (*tm_send)(struct nfc_dev *dev, struct sk_buff *skb);
70 int (*check_presence)(struct nfc_dev *dev, struct nfc_target *target); 70 int (*check_presence)(struct nfc_dev *dev, struct nfc_target *target);
71 int (*enable_se)(struct nfc_dev *dev, u32 secure_element);
72 int (*disable_se)(struct nfc_dev *dev, u32 secure_element);
73 int (*fw_upload)(struct nfc_dev *dev, const char *firmware_name); 71 int (*fw_upload)(struct nfc_dev *dev, const char *firmware_name);
72
73 /* Secure Element API */
74 int (*discover_se)(struct nfc_dev *dev);
75 int (*enable_se)(struct nfc_dev *dev, u32 se_idx);
76 int (*disable_se)(struct nfc_dev *dev, u32 se_idx);
74}; 77};
75 78
76#define NFC_TARGET_IDX_ANY -1 79#define NFC_TARGET_IDX_ANY -1
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 334954a1d6e8..a43a56d7f4be 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -126,6 +126,13 @@ int nfc_dev_up(struct nfc_dev *dev)
126 if (!rc) 126 if (!rc)
127 dev->dev_up = true; 127 dev->dev_up = true;
128 128
129 /* We have to enable the device before discovering SEs */
130 if (dev->ops->discover_se) {
131 rc = dev->ops->discover_se(dev);
132 if (!rc)
133 pr_warn("SE discovery failed\n");
134 }
135
129error: 136error:
130 device_unlock(&dev->dev); 137 device_unlock(&dev->dev);
131 return rc; 138 return rc;
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 9c8a63d341d3..7b1c186736eb 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -692,6 +692,36 @@ static int hci_check_presence(struct nfc_dev *nfc_dev,
692 return hdev->ops->check_presence(hdev, target); 692 return hdev->ops->check_presence(hdev, target);
693} 693}
694 694
695static int hci_discover_se(struct nfc_dev *nfc_dev)
696{
697 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
698
699 if (hdev->ops->discover_se)
700 return hdev->ops->discover_se(hdev);
701
702 return 0;
703}
704
705static int hci_enable_se(struct nfc_dev *nfc_dev, u32 se_idx)
706{
707 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
708
709 if (hdev->ops->enable_se)
710 return hdev->ops->enable_se(hdev, se_idx);
711
712 return 0;
713}
714
715static int hci_disable_se(struct nfc_dev *nfc_dev, u32 se_idx)
716{
717 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
718
719 if (hdev->ops->disable_se)
720 return hdev->ops->enable_se(hdev, se_idx);
721
722 return 0;
723}
724
695static void nfc_hci_failure(struct nfc_hci_dev *hdev, int err) 725static void nfc_hci_failure(struct nfc_hci_dev *hdev, int err)
696{ 726{
697 mutex_lock(&hdev->msg_tx_mutex); 727 mutex_lock(&hdev->msg_tx_mutex);
@@ -802,6 +832,9 @@ static struct nfc_ops hci_nfc_ops = {
802 .tm_send = hci_tm_send, 832 .tm_send = hci_tm_send,
803 .check_presence = hci_check_presence, 833 .check_presence = hci_check_presence,
804 .fw_upload = hci_fw_upload, 834 .fw_upload = hci_fw_upload,
835 .discover_se = hci_discover_se,
836 .enable_se = hci_enable_se,
837 .disable_se = hci_disable_se,
805}; 838};
806 839
807struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, 840struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops,
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 145bad15e113..b943d46a1644 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -636,6 +636,21 @@ static int nci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target,
636 return rc; 636 return rc;
637} 637}
638 638
639static int nci_enable_se(struct nfc_dev *nfc_dev, u32 se_idx)
640{
641 return 0;
642}
643
644static int nci_disable_se(struct nfc_dev *nfc_dev, u32 se_idx)
645{
646 return 0;
647}
648
649static int nci_discover_se(struct nfc_dev *nfc_dev)
650{
651 return 0;
652}
653
639static struct nfc_ops nci_nfc_ops = { 654static struct nfc_ops nci_nfc_ops = {
640 .dev_up = nci_dev_up, 655 .dev_up = nci_dev_up,
641 .dev_down = nci_dev_down, 656 .dev_down = nci_dev_down,
@@ -646,6 +661,9 @@ static struct nfc_ops nci_nfc_ops = {
646 .activate_target = nci_activate_target, 661 .activate_target = nci_activate_target,
647 .deactivate_target = nci_deactivate_target, 662 .deactivate_target = nci_deactivate_target,
648 .im_transceive = nci_transceive, 663 .im_transceive = nci_transceive,
664 .enable_se = nci_enable_se,
665 .disable_se = nci_disable_se,
666 .discover_se = nci_discover_se,
649}; 667};
650 668
651/* ---- Interface to NCI drivers ---- */ 669/* ---- Interface to NCI drivers ---- */