diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2012-04-10 13:43:04 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-04-12 15:10:33 -0400 |
commit | 8112a5c91d781a22d2b631f3295386b0b70de7c8 (patch) | |
tree | d4239b5d7b2dff9d24b8db793cb6729c23f901c9 /net | |
parent | 997002785e3f932fd26a0f9c3cd91d4b4861ed29 (diff) |
NFC: Add a target lost netlink event
Some chips are capable of detecting when a tag is out of the field, so
they could send a netlink event about it to userspace.
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/nfc/netlink.c | 30 | ||||
-rw-r--r-- | net/nfc/nfc.h | 1 |
2 files changed, 31 insertions, 0 deletions
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 | ||
186 | int 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 | |||
209 | nla_put_failure: | ||
210 | genlmsg_cancel(msg, hdr); | ||
211 | free_msg: | ||
212 | nlmsg_free(msg); | ||
213 | return -EMSGSIZE; | ||
214 | } | ||
215 | |||
186 | int nfc_genl_device_added(struct nfc_dev *dev) | 216 | int 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); | |||
119 | void nfc_genl_data_exit(struct nfc_genl_data *genl_data); | 119 | void nfc_genl_data_exit(struct nfc_genl_data *genl_data); |
120 | 120 | ||
121 | int nfc_genl_targets_found(struct nfc_dev *dev); | 121 | int nfc_genl_targets_found(struct nfc_dev *dev); |
122 | int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx); | ||
122 | 123 | ||
123 | int nfc_genl_device_added(struct nfc_dev *dev); | 124 | int nfc_genl_device_added(struct nfc_dev *dev); |
124 | int nfc_genl_device_removed(struct nfc_dev *dev); | 125 | int nfc_genl_device_removed(struct nfc_dev *dev); |