aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/nfc.h1
-rw-r--r--net/nfc/netlink.c30
-rw-r--r--net/nfc/nfc.h1
3 files changed, 32 insertions, 0 deletions
diff --git a/include/linux/nfc.h b/include/linux/nfc.h
index 39c1fcf089c0..0ae9b5857c83 100644
--- a/include/linux/nfc.h
+++ b/include/linux/nfc.h
@@ -70,6 +70,7 @@ enum nfc_commands {
70 NFC_EVENT_TARGETS_FOUND, 70 NFC_EVENT_TARGETS_FOUND,
71 NFC_EVENT_DEVICE_ADDED, 71 NFC_EVENT_DEVICE_ADDED,
72 NFC_EVENT_DEVICE_REMOVED, 72 NFC_EVENT_DEVICE_REMOVED,
73 NFC_EVENT_TARGET_LOST,
73/* private: internal use only */ 74/* private: internal use only */
74 __NFC_CMD_AFTER_LAST 75 __NFC_CMD_AFTER_LAST
75}; 76};
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 6404052d6c07..ebdb605f8dbd 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -183,6 +183,36 @@ free_msg:
183 return -EMSGSIZE; 183 return -EMSGSIZE;
184} 184}
185 185
186int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx)
187{
188 struct sk_buff *msg;
189 void *hdr;
190
191 msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
192 if (!msg)
193 return -ENOMEM;
194
195 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
196 NFC_EVENT_TARGET_LOST);
197 if (!hdr)
198 goto free_msg;
199
200 NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
201 NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target_idx);
202
203 genlmsg_end(msg, hdr);
204
205 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL);
206
207 return 0;
208
209nla_put_failure:
210 genlmsg_cancel(msg, hdr);
211free_msg:
212 nlmsg_free(msg);
213 return -EMSGSIZE;
214}
215
186int nfc_genl_device_added(struct nfc_dev *dev) 216int nfc_genl_device_added(struct nfc_dev *dev)
187{ 217{
188 struct sk_buff *msg; 218 struct sk_buff *msg;
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
index ec8794c1099c..2c868d2b3c57 100644
--- a/net/nfc/nfc.h
+++ b/net/nfc/nfc.h
@@ -119,6 +119,7 @@ void nfc_genl_data_init(struct nfc_genl_data *genl_data);
119void nfc_genl_data_exit(struct nfc_genl_data *genl_data); 119void nfc_genl_data_exit(struct nfc_genl_data *genl_data);
120 120
121int nfc_genl_targets_found(struct nfc_dev *dev); 121int nfc_genl_targets_found(struct nfc_dev *dev);
122int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx);
122 123
123int nfc_genl_device_added(struct nfc_dev *dev); 124int nfc_genl_device_added(struct nfc_dev *dev);
124int nfc_genl_device_removed(struct nfc_dev *dev); 125int nfc_genl_device_removed(struct nfc_dev *dev);