nfc: netlink: HCI event connectivity implementation
authorChristophe Ricard <christophe.ricard@gmail.com>
Wed, 23 Dec 2015 22:45:18 +0000 (23:45 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 29 Dec 2015 18:06:20 +0000 (19:06 +0100)
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>
include/net/nfc/nfc.h
net/nfc/core.c
net/nfc/netlink.c
net/nfc/nfc.h

index dcfcfc9c00bf56a4cf1681333e56bb21c14b23d9..1a3de8b34ad27a8f3f8cf74ddd3eb6af61ced72e 100644 (file)
@@ -299,6 +299,7 @@ void nfc_driver_failure(struct nfc_dev *dev, int err);
 
 int nfc_se_transaction(struct nfc_dev *dev, u8 se_idx,
                       struct nfc_evt_transaction *evt_transaction);
+int nfc_se_connectivity(struct nfc_dev *dev, u8 se_idx);
 int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type);
 int nfc_remove_se(struct nfc_dev *dev, u32 se_idx);
 struct nfc_se *nfc_find_se(struct nfc_dev *dev, u32 se_idx);
index 1fe3d3b362c0cdce72d8317488e8b1fc4d58ea1d..122bb81da9181ff92a964f381ea44113c5bd5025 100644 (file)
@@ -953,6 +953,19 @@ out:
 }
 EXPORT_SYMBOL(nfc_se_transaction);
 
+int nfc_se_connectivity(struct nfc_dev *dev, u8 se_idx)
+{
+       int rc;
+
+       pr_debug("connectivity: %x\n", se_idx);
+
+       device_lock(&dev->dev);
+       rc = nfc_genl_se_connectivity(dev, se_idx);
+       device_unlock(&dev->dev);
+       return rc;
+}
+EXPORT_SYMBOL(nfc_se_connectivity);
+
 static void nfc_release(struct device *d)
 {
        struct nfc_dev *dev = to_nfc_dev(d);
index f58c1fba10268b9c1336d205ff294e906dd04791..ea023b35f1c24b3069be02796b24bfad7805352e 100644 (file)
@@ -552,6 +552,43 @@ free_msg:
        return -EMSGSIZE;
 }
 
+int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx)
+{
+       struct nfc_se *se;
+       struct sk_buff *msg;
+       void *hdr;
+
+       msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+       if (!msg)
+               return -ENOMEM;
+
+       hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
+                         NFC_EVENT_SE_CONNECTIVITY);
+       if (!hdr)
+               goto free_msg;
+
+       se = nfc_find_se(dev, se_idx);
+       if (!se)
+               goto free_msg;
+
+       if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
+           nla_put_u32(msg, NFC_ATTR_SE_INDEX, se_idx) ||
+           nla_put_u8(msg, NFC_ATTR_SE_TYPE, se->type))
+               goto nla_put_failure;
+
+       genlmsg_end(msg, hdr);
+
+       genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
+
+       return 0;
+
+nla_put_failure:
+       genlmsg_cancel(msg, hdr);
+free_msg:
+       nlmsg_free(msg);
+       return -EMSGSIZE;
+}
+
 static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev,
                                u32 portid, u32 seq,
                                struct netlink_callback *cb,
index c20b784ad72069ae599bec30d8896ac693a8bda9..6c6f76b370b1e7955bcb4aa780a388719eb76b2d 100644 (file)
@@ -105,6 +105,7 @@ int nfc_genl_se_added(struct nfc_dev *dev, u32 se_idx, u16 type);
 int nfc_genl_se_removed(struct nfc_dev *dev, u32 se_idx);
 int nfc_genl_se_transaction(struct nfc_dev *dev, u8 se_idx,
                            struct nfc_evt_transaction *evt_transaction);
+int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx);
 
 struct nfc_dev *nfc_get_device(unsigned int idx);