diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2012-06-01 07:21:13 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-06-04 15:34:30 -0400 |
commit | fc40a8c1a06ab7db45da790693dd9802612a055c (patch) | |
tree | 7ad170c95ff66bce521bc25a6ddf6946cc1ab0c0 /net/nfc | |
parent | ad3823cef650bdc1ca9e7bf1a01b87ad3c0425de (diff) |
NFC: Add target mode activation netlink event
Userspace gets a netlink event upon target mode activation.
The LLCP layer is also signaled when we get an ATR_REQ in order to get
the remote general bytes.
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/core.c | 35 | ||||
-rw-r--r-- | net/nfc/netlink.c | 62 | ||||
-rw-r--r-- | net/nfc/nfc.h | 3 |
3 files changed, 100 insertions, 0 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c index c83717bfcb8a..17f147430b7c 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c | |||
@@ -455,6 +455,41 @@ u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, size_t *gb_len) | |||
455 | } | 455 | } |
456 | EXPORT_SYMBOL(nfc_get_local_general_bytes); | 456 | EXPORT_SYMBOL(nfc_get_local_general_bytes); |
457 | 457 | ||
458 | int nfc_tm_activated(struct nfc_dev *dev, u32 protocol, u8 comm_mode, | ||
459 | u8 *gb, size_t gb_len) | ||
460 | { | ||
461 | int rc; | ||
462 | |||
463 | device_lock(&dev->dev); | ||
464 | |||
465 | dev->polling = false; | ||
466 | |||
467 | if (gb != NULL) { | ||
468 | rc = nfc_set_remote_general_bytes(dev, gb, gb_len); | ||
469 | if (rc < 0) | ||
470 | goto out; | ||
471 | } | ||
472 | |||
473 | if (protocol == NFC_PROTO_NFC_DEP_MASK) | ||
474 | nfc_dep_link_is_up(dev, 0, comm_mode, NFC_RF_TARGET); | ||
475 | |||
476 | rc = nfc_genl_tm_activated(dev, protocol); | ||
477 | |||
478 | out: | ||
479 | device_unlock(&dev->dev); | ||
480 | |||
481 | return rc; | ||
482 | } | ||
483 | EXPORT_SYMBOL(nfc_tm_activated); | ||
484 | |||
485 | int nfc_tm_deactivated(struct nfc_dev *dev) | ||
486 | { | ||
487 | dev->dep_link_up = false; | ||
488 | |||
489 | return nfc_genl_tm_deactivated(dev); | ||
490 | } | ||
491 | EXPORT_SYMBOL(nfc_tm_deactivated); | ||
492 | |||
458 | /** | 493 | /** |
459 | * nfc_alloc_send_skb - allocate a skb for data exchange responses | 494 | * nfc_alloc_send_skb - allocate a skb for data exchange responses |
460 | * | 495 | * |
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index a18fd56798fc..21eaa9b5c6bf 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c | |||
@@ -221,6 +221,68 @@ free_msg: | |||
221 | return -EMSGSIZE; | 221 | return -EMSGSIZE; |
222 | } | 222 | } |
223 | 223 | ||
224 | int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol) | ||
225 | { | ||
226 | struct sk_buff *msg; | ||
227 | void *hdr; | ||
228 | |||
229 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
230 | if (!msg) | ||
231 | return -ENOMEM; | ||
232 | |||
233 | hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, | ||
234 | NFC_EVENT_TM_ACTIVATED); | ||
235 | if (!hdr) | ||
236 | goto free_msg; | ||
237 | |||
238 | if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx)) | ||
239 | goto nla_put_failure; | ||
240 | if (nla_put_u32(msg, NFC_ATTR_TM_PROTOCOLS, protocol)) | ||
241 | goto nla_put_failure; | ||
242 | |||
243 | genlmsg_end(msg, hdr); | ||
244 | |||
245 | genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); | ||
246 | |||
247 | return 0; | ||
248 | |||
249 | nla_put_failure: | ||
250 | genlmsg_cancel(msg, hdr); | ||
251 | free_msg: | ||
252 | nlmsg_free(msg); | ||
253 | return -EMSGSIZE; | ||
254 | } | ||
255 | |||
256 | int nfc_genl_tm_deactivated(struct nfc_dev *dev) | ||
257 | { | ||
258 | struct sk_buff *msg; | ||
259 | void *hdr; | ||
260 | |||
261 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
262 | if (!msg) | ||
263 | return -ENOMEM; | ||
264 | |||
265 | hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, | ||
266 | NFC_EVENT_TM_DEACTIVATED); | ||
267 | if (!hdr) | ||
268 | goto free_msg; | ||
269 | |||
270 | if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx)) | ||
271 | goto nla_put_failure; | ||
272 | |||
273 | genlmsg_end(msg, hdr); | ||
274 | |||
275 | genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); | ||
276 | |||
277 | return 0; | ||
278 | |||
279 | nla_put_failure: | ||
280 | genlmsg_cancel(msg, hdr); | ||
281 | free_msg: | ||
282 | nlmsg_free(msg); | ||
283 | return -EMSGSIZE; | ||
284 | } | ||
285 | |||
224 | int nfc_genl_device_added(struct nfc_dev *dev) | 286 | int nfc_genl_device_added(struct nfc_dev *dev) |
225 | { | 287 | { |
226 | struct sk_buff *msg; | 288 | struct sk_buff *msg; |
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index 7d9708f2a66c..cd9fcbe57464 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h | |||
@@ -128,6 +128,9 @@ int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx, | |||
128 | u8 comm_mode, u8 rf_mode); | 128 | u8 comm_mode, u8 rf_mode); |
129 | int nfc_genl_dep_link_down_event(struct nfc_dev *dev); | 129 | int nfc_genl_dep_link_down_event(struct nfc_dev *dev); |
130 | 130 | ||
131 | int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol); | ||
132 | int nfc_genl_tm_deactivated(struct nfc_dev *dev); | ||
133 | |||
131 | struct nfc_dev *nfc_get_device(unsigned int idx); | 134 | struct nfc_dev *nfc_get_device(unsigned int idx); |
132 | 135 | ||
133 | static inline void nfc_put_device(struct nfc_dev *dev) | 136 | static inline void nfc_put_device(struct nfc_dev *dev) |