aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/net/nfc/core.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-05-10 15:47:37 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-14 13:44:59 +0200
commit2757c3723c3d2b13e3a8bfaa034826f64e9cca43 (patch)
tree05a2c978fc9edbc973f1f6b55afbddf6ccb79f55 /net/nfc/core.c
parentNFC: Add secure elements addition and removal API (diff)
downloadwireguard-linux-2757c3723c3d2b13e3a8bfaa034826f64e9cca43.tar.xz
wireguard-linux-2757c3723c3d2b13e3a8bfaa034826f64e9cca43.zip
NFC: Send netlink events for secure elements additions and removals
When an NFC driver or host controller stack discovers a secure element, it will call nfc_add_se(). In order for userspace applications to use these secure elements, a netlink event will then be sent with the SE index and its type. With that information userspace applications can decide wether or not to enable SEs, through their indexes. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc/core.c')
-rw-r--r--net/nfc/core.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c
index dacadfbcacea..bb5f16cfc201 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -763,6 +763,7 @@ EXPORT_SYMBOL(nfc_driver_failure);
int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type)
{
struct nfc_se *se, *n;
+ int rc;
pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
@@ -781,6 +782,14 @@ int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type)
list_add(&se->list, &dev->secure_elements);
+ rc = nfc_genl_se_added(dev, se_idx, type);
+ if (rc < 0) {
+ list_del(&se->list);
+ kfree(se);
+
+ return rc;
+ }
+
return 0;
}
EXPORT_SYMBOL(nfc_add_se);
@@ -788,11 +797,16 @@ EXPORT_SYMBOL(nfc_add_se);
int nfc_remove_se(struct nfc_dev *dev, u32 se_idx)
{
struct nfc_se *se, *n;
+ int rc;
pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
list_for_each_entry_safe(se, n, &dev->secure_elements, list)
if (se->idx == se_idx) {
+ rc = nfc_genl_se_removed(dev, se_idx);
+ if (rc < 0)
+ return rc;
+
list_del(&se->list);
kfree(se);