Skip to content

Commit

Permalink
Merge tag 'nfc-next-3.20-2' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/sameo/nfc-next

NFC: 3.20 second pull request

This is the second NFC pull request for 3.20.

It brings:

- NCI NFCEE (NFC Execution Environment, typically an embedded or
  external secure element) discovery and enabling/disabling support.
  In order to communicate with an NFCEE, we also added NCI's logical
  connections support to the NCI stack.

- HCI over NCI protocol support. Some secure elements only understand
  HCI and thus we need to send them HCI frames when they're part of
  an NCI chipset.

- NFC_EVT_TRANSACTION userspace API addition. Whenever an application
  running on a secure element needs to notify its host counterpart,
  we send an NFC_EVENT_SE_TRANSACTION event to userspace through the
  NFC netlink socket.

- Secure element and HCI transaction event support for the st21nfcb
  chipset.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Feb 8, 2015
2 parents 020219a + fa00e8f commit 3c09e92
Show file tree
Hide file tree
Showing 19 changed files with 2,203 additions and 51 deletions.
21 changes: 21 additions & 0 deletions drivers/nfc/st21nfca/st21nfca_se.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,34 @@ 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);

switch (event) {
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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/nfc/st21nfcb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile for ST21NFCB NCI based NFC driver
#

st21nfcb_nci-objs = ndlc.o st21nfcb.o
st21nfcb_nci-objs = ndlc.o st21nfcb.o st21nfcb_se.o
obj-$(CONFIG_NFC_ST21NFCB) += st21nfcb_nci.o

st21nfcb_i2c-objs = i2c.o
Expand Down
11 changes: 10 additions & 1 deletion drivers/nfc/st21nfcb/st21nfcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <net/nfc/nci_core.h>

#include "st21nfcb.h"
#include "st21nfcb_se.h"

#define DRIVER_DESC "NCI NFC driver for ST21NFCB"

Expand Down Expand Up @@ -78,6 +79,13 @@ static struct nci_ops st21nfcb_nci_ops = {
.close = st21nfcb_nci_close,
.send = st21nfcb_nci_send,
.get_rfprotocol = st21nfcb_nci_get_rfprotocol,
.discover_se = st21nfcb_nci_discover_se,
.enable_se = st21nfcb_nci_enable_se,
.disable_se = st21nfcb_nci_disable_se,
.se_io = st21nfcb_nci_se_io,
.hci_load_session = st21nfcb_hci_load_session,
.hci_event_received = st21nfcb_hci_event_received,
.hci_cmd_received = st21nfcb_hci_cmd_received,
};

int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
Expand Down Expand Up @@ -114,9 +122,10 @@ int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
if (r) {
pr_err("Cannot register nfc device to nci core\n");
nci_free_device(ndlc->ndev);
return r;
}

return r;
return st21nfcb_se_init(ndlc->ndev);
}
EXPORT_SYMBOL_GPL(st21nfcb_nci_probe);

Expand Down
2 changes: 2 additions & 0 deletions drivers/nfc/st21nfcb/st21nfcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef __LOCAL_ST21NFCB_H_
#define __LOCAL_ST21NFCB_H_

#include "st21nfcb_se.h"
#include "ndlc.h"

/* Define private flags: */
Expand All @@ -27,6 +28,7 @@
struct st21nfcb_nci_info {
struct llt_ndlc *ndlc;
unsigned long flags;
struct st21nfcb_se_info se_info;
};

void st21nfcb_nci_remove(struct nci_dev *ndev);
Expand Down
Loading

0 comments on commit 3c09e92

Please sign in to comment.