aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2015-12-23 17:45:18 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2015-12-29 13:06:20 -0500
commit9afec6d3866b8451abcf1a7a1a381a3be6c83386 (patch)
tree8286f9115386f6b5f2f319381ceffe52e9c2793c /net/nfc
parentdfa4089b3a3f3ac8bea847f968c92b89fbbf107c (diff)
nfc: netlink: HCI event connectivity implementation
Add support for missing HCI event EVT_CONNECTIVITY and forward it to userspace. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/core.c13
-rw-r--r--net/nfc/netlink.c37
-rw-r--r--net/nfc/nfc.h1
3 files changed, 51 insertions, 0 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 1fe3d3b362c0..122bb81da918 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -953,6 +953,19 @@ out:
953} 953}
954EXPORT_SYMBOL(nfc_se_transaction); 954EXPORT_SYMBOL(nfc_se_transaction);
955 955
956int nfc_se_connectivity(struct nfc_dev *dev, u8 se_idx)
957{
958 int rc;
959
960 pr_debug("connectivity: %x\n", se_idx);
961
962 device_lock(&dev->dev);
963 rc = nfc_genl_se_connectivity(dev, se_idx);
964 device_unlock(&dev->dev);
965 return rc;
966}
967EXPORT_SYMBOL(nfc_se_connectivity);
968
956static void nfc_release(struct device *d) 969static void nfc_release(struct device *d)
957{ 970{
958 struct nfc_dev *dev = to_nfc_dev(d); 971 struct nfc_dev *dev = to_nfc_dev(d);
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index f58c1fba1026..ea023b35f1c2 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -552,6 +552,43 @@ free_msg:
552 return -EMSGSIZE; 552 return -EMSGSIZE;
553} 553}
554 554
555int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx)
556{
557 struct nfc_se *se;
558 struct sk_buff *msg;
559 void *hdr;
560
561 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
562 if (!msg)
563 return -ENOMEM;
564
565 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
566 NFC_EVENT_SE_CONNECTIVITY);
567 if (!hdr)
568 goto free_msg;
569
570 se = nfc_find_se(dev, se_idx);
571 if (!se)
572 goto free_msg;
573
574 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
575 nla_put_u32(msg, NFC_ATTR_SE_INDEX, se_idx) ||
576 nla_put_u8(msg, NFC_ATTR_SE_TYPE, se->type))
577 goto nla_put_failure;
578
579 genlmsg_end(msg, hdr);
580
581 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
582
583 return 0;
584
585nla_put_failure:
586 genlmsg_cancel(msg, hdr);
587free_msg:
588 nlmsg_free(msg);
589 return -EMSGSIZE;
590}
591
555static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev, 592static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev,
556 u32 portid, u32 seq, 593 u32 portid, u32 seq,
557 struct netlink_callback *cb, 594 struct netlink_callback *cb,
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
index c20b784ad720..6c6f76b370b1 100644
--- a/net/nfc/nfc.h
+++ b/net/nfc/nfc.h
@@ -105,6 +105,7 @@ int nfc_genl_se_added(struct nfc_dev *dev, u32 se_idx, u16 type);
105int nfc_genl_se_removed(struct nfc_dev *dev, u32 se_idx); 105int nfc_genl_se_removed(struct nfc_dev *dev, u32 se_idx);
106int nfc_genl_se_transaction(struct nfc_dev *dev, u8 se_idx, 106int nfc_genl_se_transaction(struct nfc_dev *dev, u8 se_idx,
107 struct nfc_evt_transaction *evt_transaction); 107 struct nfc_evt_transaction *evt_transaction);
108int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx);
108 109
109struct nfc_dev *nfc_get_device(unsigned int idx); 110struct nfc_dev *nfc_get_device(unsigned int idx);
110 111