diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2015-02-01 22:26:20 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2015-02-02 21:50:42 +0100 |
commit | 26fc6c7f02cb26c39c4733de3dbc3c0646fc1074 (patch) | |
tree | d651a9bde40c2a44b6ff92b3895d86ed5608b0cc /drivers/nfc | |
parent | 5d1ceb7f5e56aeec0d541a76293ba3de5af78795 (diff) | |
download | op-kernel-dev-26fc6c7f02cb26c39c4733de3dbc3c0646fc1074.zip op-kernel-dev-26fc6c7f02cb26c39c4733de3dbc3c0646fc1074.tar.gz |
NFC: st21nfca: Add HCI transaction event support
The transaction notifies the host (DH) that an action
is required to manage a specific Secure Element application.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/st21nfca/st21nfca_se.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/nfc/st21nfca/st21nfca_se.c b/drivers/nfc/st21nfca/st21nfca_se.c index 9b93d390..bd13cac 100644 --- a/drivers/nfc/st21nfca/st21nfca_se.c +++ b/drivers/nfc/st21nfca/st21nfca_se.c @@ -301,6 +301,8 @@ int st21nfca_connectivity_event_received(struct nfc_hci_dev *hdev, u8 host, u8 event, struct sk_buff *skb) { int r = 0; + struct device *dev = &hdev->ndev->dev; + struct nfc_evt_transaction *transaction; pr_debug("connectivity gate event: %x\n", event); @@ -308,6 +310,25 @@ int st21nfca_connectivity_event_received(struct nfc_hci_dev *hdev, u8 host, case ST21NFCA_EVT_CONNECTIVITY: break; case ST21NFCA_EVT_TRANSACTION: + if (skb->len < NFC_MIN_AID_LENGTH + 2 && + skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG) + return -EPROTO; + + transaction = (struct nfc_evt_transaction *)devm_kzalloc(dev, + skb->len - 2, GFP_KERNEL); + + transaction->aid_len = skb->data[1]; + memcpy(transaction->aid, &skb->data[2], skb->data[1]); + + if (skb->data[transaction->aid_len + 2] != + NFC_EVT_TRANSACTION_PARAMS_TAG) + return -EPROTO; + + transaction->params_len = skb->data[transaction->aid_len + 3]; + memcpy(transaction->params, skb->data + + transaction->aid_len + 4, transaction->params_len); + + r = nfc_se_transaction(hdev->ndev, host, transaction); break; default: return 1; |