24 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
28 #include <linux/slab.h>
66 genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
86 return genlmsg_end(msg, hdr);
89 genlmsg_cancel(msg, hdr);
118 static int nfc_genl_dump_targets(
struct sk_buff *
skb,
126 dev = __get_device_from_cb(cb);
133 device_lock(&dev->
dev);
138 rc = nfc_genl_send_target(skb, &dev->
targets[i], cb,
146 device_unlock(&dev->
dev);
180 goto nla_put_failure;
182 genlmsg_end(msg, hdr);
184 return genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.
id,
GFP_ATOMIC);
187 genlmsg_cancel(msg, hdr);
209 goto nla_put_failure;
211 genlmsg_end(msg, hdr);
213 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.
id,
GFP_KERNEL);
218 genlmsg_cancel(msg, hdr);
239 goto nla_put_failure;
241 goto nla_put_failure;
243 genlmsg_end(msg, hdr);
245 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.
id,
GFP_KERNEL);
250 genlmsg_cancel(msg, hdr);
271 goto nla_put_failure;
273 genlmsg_end(msg, hdr);
275 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.
id,
GFP_KERNEL);
280 genlmsg_cancel(msg, hdr);
304 goto nla_put_failure;
306 genlmsg_end(msg, hdr);
308 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.
id,
GFP_KERNEL);
313 genlmsg_cancel(msg, hdr);
334 goto nla_put_failure;
336 genlmsg_end(msg, hdr);
338 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.
id,
GFP_KERNEL);
343 genlmsg_cancel(msg, hdr);
349 static int nfc_genl_send_device(
struct sk_buff *msg,
struct nfc_dev *dev,
356 hdr =
genlmsg_put(msg, portid, seq, &nfc_genl_family, flags,
362 genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
368 goto nla_put_failure;
370 return genlmsg_end(msg, hdr);
373 genlmsg_cancel(msg, hdr);
377 static int nfc_genl_dump_devices(
struct sk_buff *skb,
382 bool first_call =
false;
397 nfc_device_iter_init(iter);
398 dev = nfc_device_iter_next(iter);
404 rc = nfc_genl_send_device(skb, dev,
NETLINK_CB(cb->
skb).portid,
409 dev = nfc_device_iter_next(iter);
423 nfc_device_iter_exit(iter);
430 u8 comm_mode,
u8 rf_mode)
446 goto nla_put_failure;
449 goto nla_put_failure;
452 goto nla_put_failure;
454 genlmsg_end(msg, hdr);
458 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.
id,
GFP_ATOMIC);
463 genlmsg_cancel(msg, hdr);
486 goto nla_put_failure;
488 genlmsg_end(msg, hdr);
490 genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.
id,
GFP_ATOMIC);
495 genlmsg_cancel(msg, hdr);
530 return genlmsg_reply(msg, info);
586 u32 im_protocols = 0, tm_protocols = 0;
637 device_lock(&dev->
dev);
640 device_unlock(&dev->
dev);
644 device_unlock(&dev->
dev);
662 static int nfc_genl_dep_link_up(
struct sk_buff *skb,
struct genl_info *info)
697 static int nfc_genl_dep_link_down(
struct sk_buff *skb,
struct genl_info *info)
718 static struct genl_ops nfc_genl_ops[] = {
721 .doit = nfc_genl_get_device,
722 .dumpit = nfc_genl_dump_devices,
723 .done = nfc_genl_dump_devices_done,
724 .policy = nfc_genl_policy,
728 .doit = nfc_genl_dev_up,
729 .policy = nfc_genl_policy,
733 .doit = nfc_genl_dev_down,
734 .policy = nfc_genl_policy,
738 .doit = nfc_genl_start_poll,
739 .policy = nfc_genl_policy,
743 .doit = nfc_genl_stop_poll,
744 .policy = nfc_genl_policy,
748 .doit = nfc_genl_dep_link_up,
749 .policy = nfc_genl_policy,
753 .doit = nfc_genl_dep_link_down,
754 .policy = nfc_genl_policy,
758 .dumpit = nfc_genl_dump_targets,
759 .done = nfc_genl_dump_targets_done,
760 .policy = nfc_genl_policy,
780 nfc_device_iter_init(&iter);
781 dev = nfc_device_iter_next(&iter);
793 dev = nfc_device_iter_next(&iter);
796 nfc_device_iter_exit(&iter);
837 .notifier_call = nfc_genl_rcv_nl_event,