2 * Copyright (C) 2011 Instituto Nokia de Tecnologia
5 * Lauro Ramos Venancio <lauro.venancio@openbossa.org>
6 * Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
8 * Vendor commands implementation based on net/wireless/nl80211.c
11 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
12 * Copyright 2013-2014 Intel Mobile Communications GmbH
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see <http://www.gnu.org/licenses/>.
28 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
30 #include <net/genetlink.h>
31 #include <linux/nfc.h>
32 #include <linux/slab.h>
37 static const struct genl_multicast_group nfc_genl_mcgrps[] = {
38 { .name = NFC_GENL_MCAST_EVENT_NAME, },
41 static struct genl_family nfc_genl_family = {
42 .id = GENL_ID_GENERATE,
44 .name = NFC_GENL_NAME,
45 .version = NFC_GENL_VERSION,
46 .maxattr = NFC_ATTR_MAX,
49 static const struct nla_policy nfc_genl_policy[NFC_ATTR_MAX + 1] = {
50 [NFC_ATTR_DEVICE_INDEX] = { .type = NLA_U32 },
51 [NFC_ATTR_DEVICE_NAME] = { .type = NLA_STRING,
52 .len = NFC_DEVICE_NAME_MAXSIZE },
53 [NFC_ATTR_PROTOCOLS] = { .type = NLA_U32 },
54 [NFC_ATTR_COMM_MODE] = { .type = NLA_U8 },
55 [NFC_ATTR_RF_MODE] = { .type = NLA_U8 },
56 [NFC_ATTR_DEVICE_POWERED] = { .type = NLA_U8 },
57 [NFC_ATTR_IM_PROTOCOLS] = { .type = NLA_U32 },
58 [NFC_ATTR_TM_PROTOCOLS] = { .type = NLA_U32 },
59 [NFC_ATTR_LLC_PARAM_LTO] = { .type = NLA_U8 },
60 [NFC_ATTR_LLC_PARAM_RW] = { .type = NLA_U8 },
61 [NFC_ATTR_LLC_PARAM_MIUX] = { .type = NLA_U16 },
62 [NFC_ATTR_LLC_SDP] = { .type = NLA_NESTED },
63 [NFC_ATTR_FIRMWARE_NAME] = { .type = NLA_STRING,
64 .len = NFC_FIRMWARE_NAME_MAXSIZE },
65 [NFC_ATTR_SE_INDEX] = { .type = NLA_U32 },
66 [NFC_ATTR_SE_APDU] = { .type = NLA_BINARY },
67 [NFC_ATTR_VENDOR_ID] = { .type = NLA_U32 },
68 [NFC_ATTR_VENDOR_SUBCMD] = { .type = NLA_U32 },
69 [NFC_ATTR_VENDOR_DATA] = { .type = NLA_BINARY },
73 static const struct nla_policy nfc_sdp_genl_policy[NFC_SDP_ATTR_MAX + 1] = {
74 [NFC_SDP_ATTR_URI] = { .type = NLA_STRING,
76 [NFC_SDP_ATTR_SAP] = { .type = NLA_U8 },
79 static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,
80 struct netlink_callback *cb, int flags)
84 hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
85 &nfc_genl_family, flags, NFC_CMD_GET_TARGET);
89 genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
91 if (nla_put_u32(msg, NFC_ATTR_TARGET_INDEX, target->idx) ||
92 nla_put_u32(msg, NFC_ATTR_PROTOCOLS, target->supported_protocols) ||
93 nla_put_u16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res) ||
94 nla_put_u8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res))
96 if (target->nfcid1_len > 0 &&
97 nla_put(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len,
100 if (target->sensb_res_len > 0 &&
101 nla_put(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len,
103 goto nla_put_failure;
104 if (target->sensf_res_len > 0 &&
105 nla_put(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len,
107 goto nla_put_failure;
109 if (target->is_iso15693) {
110 if (nla_put_u8(msg, NFC_ATTR_TARGET_ISO15693_DSFID,
111 target->iso15693_dsfid) ||
112 nla_put(msg, NFC_ATTR_TARGET_ISO15693_UID,
113 sizeof(target->iso15693_uid), target->iso15693_uid))
114 goto nla_put_failure;
117 genlmsg_end(msg, hdr);
121 genlmsg_cancel(msg, hdr);
125 static struct nfc_dev *__get_device_from_cb(struct netlink_callback *cb)
131 rc = nlmsg_parse(cb->nlh, GENL_HDRLEN + nfc_genl_family.hdrsize,
132 nfc_genl_family.attrbuf,
133 nfc_genl_family.maxattr,
138 if (!nfc_genl_family.attrbuf[NFC_ATTR_DEVICE_INDEX])
139 return ERR_PTR(-EINVAL);
141 idx = nla_get_u32(nfc_genl_family.attrbuf[NFC_ATTR_DEVICE_INDEX]);
143 dev = nfc_get_device(idx);
145 return ERR_PTR(-ENODEV);
150 static int nfc_genl_dump_targets(struct sk_buff *skb,
151 struct netlink_callback *cb)
154 struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
158 dev = __get_device_from_cb(cb);
162 cb->args[1] = (long) dev;
165 device_lock(&dev->dev);
167 cb->seq = dev->targets_generation;
169 while (i < dev->n_targets) {
170 rc = nfc_genl_send_target(skb, &dev->targets[i], cb,
178 device_unlock(&dev->dev);
185 static int nfc_genl_dump_targets_done(struct netlink_callback *cb)
187 struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
195 int nfc_genl_targets_found(struct nfc_dev *dev)
200 dev->genl_data.poll_req_portid = 0;
202 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
206 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
207 NFC_EVENT_TARGETS_FOUND);
211 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
212 goto nla_put_failure;
214 genlmsg_end(msg, hdr);
216 return genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
219 genlmsg_cancel(msg, hdr);
225 int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx)
230 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
234 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
235 NFC_EVENT_TARGET_LOST);
239 if (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) ||
240 nla_put_u32(msg, NFC_ATTR_TARGET_INDEX, target_idx))
241 goto nla_put_failure;
243 genlmsg_end(msg, hdr);
245 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
250 genlmsg_cancel(msg, hdr);
256 int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol)
261 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
265 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
266 NFC_EVENT_TM_ACTIVATED);
270 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
271 goto nla_put_failure;
272 if (nla_put_u32(msg, NFC_ATTR_TM_PROTOCOLS, protocol))
273 goto nla_put_failure;
275 genlmsg_end(msg, hdr);
277 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
282 genlmsg_cancel(msg, hdr);
288 int nfc_genl_tm_deactivated(struct nfc_dev *dev)
293 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
297 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
298 NFC_EVENT_TM_DEACTIVATED);
302 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
303 goto nla_put_failure;
305 genlmsg_end(msg, hdr);
307 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
312 genlmsg_cancel(msg, hdr);
318 int nfc_genl_device_added(struct nfc_dev *dev)
323 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
327 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
328 NFC_EVENT_DEVICE_ADDED);
332 if (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) ||
333 nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
334 nla_put_u32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols) ||
335 nla_put_u8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up))
336 goto nla_put_failure;
338 genlmsg_end(msg, hdr);
340 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
345 genlmsg_cancel(msg, hdr);
351 int nfc_genl_device_removed(struct nfc_dev *dev)
356 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
360 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
361 NFC_EVENT_DEVICE_REMOVED);
365 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
366 goto nla_put_failure;
368 genlmsg_end(msg, hdr);
370 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
375 genlmsg_cancel(msg, hdr);
381 int nfc_genl_llc_send_sdres(struct nfc_dev *dev, struct hlist_head *sdres_list)
384 struct nlattr *sdp_attr, *uri_attr;
385 struct nfc_llcp_sdp_tlv *sdres;
386 struct hlist_node *n;
391 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
395 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
396 NFC_EVENT_LLC_SDRES);
400 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
401 goto nla_put_failure;
403 sdp_attr = nla_nest_start(msg, NFC_ATTR_LLC_SDP);
404 if (sdp_attr == NULL) {
406 goto nla_put_failure;
410 hlist_for_each_entry_safe(sdres, n, sdres_list, node) {
411 pr_debug("uri: %s, sap: %d\n", sdres->uri, sdres->sap);
413 uri_attr = nla_nest_start(msg, i++);
414 if (uri_attr == NULL) {
416 goto nla_put_failure;
419 if (nla_put_u8(msg, NFC_SDP_ATTR_SAP, sdres->sap))
420 goto nla_put_failure;
422 if (nla_put_string(msg, NFC_SDP_ATTR_URI, sdres->uri))
423 goto nla_put_failure;
425 nla_nest_end(msg, uri_attr);
427 hlist_del(&sdres->node);
429 nfc_llcp_free_sdp_tlv(sdres);
432 nla_nest_end(msg, sdp_attr);
434 genlmsg_end(msg, hdr);
436 return genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
439 genlmsg_cancel(msg, hdr);
444 nfc_llcp_free_sdp_tlv_list(sdres_list);
449 int nfc_genl_se_added(struct nfc_dev *dev, u32 se_idx, u16 type)
454 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
458 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
463 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
464 nla_put_u32(msg, NFC_ATTR_SE_INDEX, se_idx) ||
465 nla_put_u8(msg, NFC_ATTR_SE_TYPE, type))
466 goto nla_put_failure;
468 genlmsg_end(msg, hdr);
470 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
475 genlmsg_cancel(msg, hdr);
481 int nfc_genl_se_removed(struct nfc_dev *dev, u32 se_idx)
486 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
490 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
491 NFC_EVENT_SE_REMOVED);
495 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
496 nla_put_u32(msg, NFC_ATTR_SE_INDEX, se_idx))
497 goto nla_put_failure;
499 genlmsg_end(msg, hdr);
501 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
506 genlmsg_cancel(msg, hdr);
512 int nfc_genl_se_transaction(struct nfc_dev *dev, u8 se_idx,
513 struct nfc_evt_transaction *evt_transaction)
519 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
523 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
524 NFC_EVENT_SE_TRANSACTION);
528 se = nfc_find_se(dev, se_idx);
532 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
533 nla_put_u32(msg, NFC_ATTR_SE_INDEX, se_idx) ||
534 nla_put_u8(msg, NFC_ATTR_SE_TYPE, se->type) ||
535 nla_put(msg, NFC_ATTR_SE_AID, evt_transaction->aid_len,
536 evt_transaction->aid) ||
537 nla_put(msg, NFC_ATTR_SE_PARAMS, evt_transaction->params_len,
538 evt_transaction->params))
539 goto nla_put_failure;
541 /* evt_transaction is no more used */
542 devm_kfree(&dev->dev, evt_transaction);
544 genlmsg_end(msg, hdr);
546 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
551 genlmsg_cancel(msg, hdr);
553 /* evt_transaction is no more used */
554 devm_kfree(&dev->dev, evt_transaction);
559 int nfc_genl_se_connectivity(struct nfc_dev *dev, u8 se_idx)
565 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
569 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
570 NFC_EVENT_SE_CONNECTIVITY);
574 se = nfc_find_se(dev, se_idx);
578 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
579 nla_put_u32(msg, NFC_ATTR_SE_INDEX, se_idx) ||
580 nla_put_u8(msg, NFC_ATTR_SE_TYPE, se->type))
581 goto nla_put_failure;
583 genlmsg_end(msg, hdr);
585 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
590 genlmsg_cancel(msg, hdr);
596 static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev,
598 struct netlink_callback *cb,
603 hdr = genlmsg_put(msg, portid, seq, &nfc_genl_family, flags,
609 genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
611 if (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) ||
612 nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
613 nla_put_u32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols) ||
614 nla_put_u8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up) ||
615 nla_put_u8(msg, NFC_ATTR_RF_MODE, dev->rf_mode))
616 goto nla_put_failure;
618 genlmsg_end(msg, hdr);
622 genlmsg_cancel(msg, hdr);
626 static int nfc_genl_dump_devices(struct sk_buff *skb,
627 struct netlink_callback *cb)
629 struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
630 struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
631 bool first_call = false;
635 iter = kmalloc(sizeof(struct class_dev_iter), GFP_KERNEL);
638 cb->args[0] = (long) iter;
641 mutex_lock(&nfc_devlist_mutex);
643 cb->seq = nfc_devlist_generation;
646 nfc_device_iter_init(iter);
647 dev = nfc_device_iter_next(iter);
653 rc = nfc_genl_send_device(skb, dev, NETLINK_CB(cb->skb).portid,
654 cb->nlh->nlmsg_seq, cb, NLM_F_MULTI);
658 dev = nfc_device_iter_next(iter);
661 mutex_unlock(&nfc_devlist_mutex);
663 cb->args[1] = (long) dev;
668 static int nfc_genl_dump_devices_done(struct netlink_callback *cb)
670 struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
673 nfc_device_iter_exit(iter);
680 int nfc_genl_dep_link_up_event(struct nfc_dev *dev, u32 target_idx,
681 u8 comm_mode, u8 rf_mode)
686 pr_debug("DEP link is up\n");
688 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
692 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, NFC_CMD_DEP_LINK_UP);
696 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
697 goto nla_put_failure;
698 if (rf_mode == NFC_RF_INITIATOR &&
699 nla_put_u32(msg, NFC_ATTR_TARGET_INDEX, target_idx))
700 goto nla_put_failure;
701 if (nla_put_u8(msg, NFC_ATTR_COMM_MODE, comm_mode) ||
702 nla_put_u8(msg, NFC_ATTR_RF_MODE, rf_mode))
703 goto nla_put_failure;
705 genlmsg_end(msg, hdr);
707 dev->dep_link_up = true;
709 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
714 genlmsg_cancel(msg, hdr);
720 int nfc_genl_dep_link_down_event(struct nfc_dev *dev)
725 pr_debug("DEP link is down\n");
727 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
731 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
732 NFC_CMD_DEP_LINK_DOWN);
736 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
737 goto nla_put_failure;
739 genlmsg_end(msg, hdr);
741 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
746 genlmsg_cancel(msg, hdr);
752 static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info)
759 if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
762 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
764 dev = nfc_get_device(idx);
768 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
774 rc = nfc_genl_send_device(msg, dev, info->snd_portid, info->snd_seq,
781 return genlmsg_reply(msg, info);
790 static int nfc_genl_dev_up(struct sk_buff *skb, struct genl_info *info)
796 if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
799 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
801 dev = nfc_get_device(idx);
805 rc = nfc_dev_up(dev);
811 static int nfc_genl_dev_down(struct sk_buff *skb, struct genl_info *info)
817 if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
820 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
822 dev = nfc_get_device(idx);
826 rc = nfc_dev_down(dev);
832 static int nfc_genl_start_poll(struct sk_buff *skb, struct genl_info *info)
837 u32 im_protocols = 0, tm_protocols = 0;
839 pr_debug("Poll start\n");
841 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
842 ((!info->attrs[NFC_ATTR_IM_PROTOCOLS] &&
843 !info->attrs[NFC_ATTR_PROTOCOLS]) &&
844 !info->attrs[NFC_ATTR_TM_PROTOCOLS]))
847 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
849 if (info->attrs[NFC_ATTR_TM_PROTOCOLS])
850 tm_protocols = nla_get_u32(info->attrs[NFC_ATTR_TM_PROTOCOLS]);
852 if (info->attrs[NFC_ATTR_IM_PROTOCOLS])
853 im_protocols = nla_get_u32(info->attrs[NFC_ATTR_IM_PROTOCOLS]);
854 else if (info->attrs[NFC_ATTR_PROTOCOLS])
855 im_protocols = nla_get_u32(info->attrs[NFC_ATTR_PROTOCOLS]);
857 dev = nfc_get_device(idx);
861 mutex_lock(&dev->genl_data.genl_data_mutex);
863 rc = nfc_start_poll(dev, im_protocols, tm_protocols);
865 dev->genl_data.poll_req_portid = info->snd_portid;
867 mutex_unlock(&dev->genl_data.genl_data_mutex);
873 static int nfc_genl_stop_poll(struct sk_buff *skb, struct genl_info *info)
879 if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
882 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
884 dev = nfc_get_device(idx);
888 device_lock(&dev->dev);
891 device_unlock(&dev->dev);
896 device_unlock(&dev->dev);
898 mutex_lock(&dev->genl_data.genl_data_mutex);
900 if (dev->genl_data.poll_req_portid != info->snd_portid) {
905 rc = nfc_stop_poll(dev);
906 dev->genl_data.poll_req_portid = 0;
909 mutex_unlock(&dev->genl_data.genl_data_mutex);
914 static int nfc_genl_activate_target(struct sk_buff *skb, struct genl_info *info)
917 u32 device_idx, target_idx, protocol;
920 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
921 !info->attrs[NFC_ATTR_TARGET_INDEX] ||
922 !info->attrs[NFC_ATTR_PROTOCOLS])
925 device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
927 dev = nfc_get_device(device_idx);
931 target_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]);
932 protocol = nla_get_u32(info->attrs[NFC_ATTR_PROTOCOLS]);
934 nfc_deactivate_target(dev, target_idx, NFC_TARGET_MODE_SLEEP);
935 rc = nfc_activate_target(dev, target_idx, protocol);
941 static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info)
948 pr_debug("DEP link up\n");
950 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
951 !info->attrs[NFC_ATTR_COMM_MODE])
954 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
955 if (!info->attrs[NFC_ATTR_TARGET_INDEX])
956 tgt_idx = NFC_TARGET_IDX_ANY;
958 tgt_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]);
960 comm = nla_get_u8(info->attrs[NFC_ATTR_COMM_MODE]);
962 if (comm != NFC_COMM_ACTIVE && comm != NFC_COMM_PASSIVE)
965 dev = nfc_get_device(idx);
969 rc = nfc_dep_link_up(dev, tgt_idx, comm);
976 static int nfc_genl_dep_link_down(struct sk_buff *skb, struct genl_info *info)
982 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
983 !info->attrs[NFC_ATTR_TARGET_INDEX])
986 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
988 dev = nfc_get_device(idx);
992 rc = nfc_dep_link_down(dev);
998 static int nfc_genl_send_params(struct sk_buff *msg,
999 struct nfc_llcp_local *local,
1000 u32 portid, u32 seq)
1004 hdr = genlmsg_put(msg, portid, seq, &nfc_genl_family, 0,
1005 NFC_CMD_LLC_GET_PARAMS);
1009 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, local->dev->idx) ||
1010 nla_put_u8(msg, NFC_ATTR_LLC_PARAM_LTO, local->lto) ||
1011 nla_put_u8(msg, NFC_ATTR_LLC_PARAM_RW, local->rw) ||
1012 nla_put_u16(msg, NFC_ATTR_LLC_PARAM_MIUX, be16_to_cpu(local->miux)))
1013 goto nla_put_failure;
1015 genlmsg_end(msg, hdr);
1020 genlmsg_cancel(msg, hdr);
1024 static int nfc_genl_llc_get_params(struct sk_buff *skb, struct genl_info *info)
1026 struct nfc_dev *dev;
1027 struct nfc_llcp_local *local;
1029 struct sk_buff *msg = NULL;
1032 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1033 !info->attrs[NFC_ATTR_FIRMWARE_NAME])
1036 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1038 dev = nfc_get_device(idx);
1042 device_lock(&dev->dev);
1044 local = nfc_llcp_find_local(dev);
1050 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1056 rc = nfc_genl_send_params(msg, local, info->snd_portid, info->snd_seq);
1059 device_unlock(&dev->dev);
1061 nfc_put_device(dev);
1070 return genlmsg_reply(msg, info);
1073 static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info)
1075 struct nfc_dev *dev;
1076 struct nfc_llcp_local *local;
1082 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1083 (!info->attrs[NFC_ATTR_LLC_PARAM_LTO] &&
1084 !info->attrs[NFC_ATTR_LLC_PARAM_RW] &&
1085 !info->attrs[NFC_ATTR_LLC_PARAM_MIUX]))
1088 if (info->attrs[NFC_ATTR_LLC_PARAM_RW]) {
1089 rw = nla_get_u8(info->attrs[NFC_ATTR_LLC_PARAM_RW]);
1091 if (rw > LLCP_MAX_RW)
1095 if (info->attrs[NFC_ATTR_LLC_PARAM_MIUX]) {
1096 miux = nla_get_u16(info->attrs[NFC_ATTR_LLC_PARAM_MIUX]);
1098 if (miux > LLCP_MAX_MIUX)
1102 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1104 dev = nfc_get_device(idx);
1108 device_lock(&dev->dev);
1110 local = nfc_llcp_find_local(dev);
1116 if (info->attrs[NFC_ATTR_LLC_PARAM_LTO]) {
1117 if (dev->dep_link_up) {
1122 local->lto = nla_get_u8(info->attrs[NFC_ATTR_LLC_PARAM_LTO]);
1125 if (info->attrs[NFC_ATTR_LLC_PARAM_RW])
1128 if (info->attrs[NFC_ATTR_LLC_PARAM_MIUX])
1129 local->miux = cpu_to_be16(miux);
1132 device_unlock(&dev->dev);
1134 nfc_put_device(dev);
1139 static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)
1141 struct nfc_dev *dev;
1142 struct nfc_llcp_local *local;
1143 struct nlattr *attr, *sdp_attrs[NFC_SDP_ATTR_MAX+1];
1148 size_t uri_len, tlvs_len;
1149 struct hlist_head sdreq_list;
1150 struct nfc_llcp_sdp_tlv *sdreq;
1152 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1153 !info->attrs[NFC_ATTR_LLC_SDP])
1156 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1158 dev = nfc_get_device(idx);
1162 device_lock(&dev->dev);
1164 if (dev->dep_link_up == false) {
1169 local = nfc_llcp_find_local(dev);
1175 INIT_HLIST_HEAD(&sdreq_list);
1179 nla_for_each_nested(attr, info->attrs[NFC_ATTR_LLC_SDP], rem) {
1180 rc = nla_parse_nested(sdp_attrs, NFC_SDP_ATTR_MAX, attr,
1181 nfc_sdp_genl_policy);
1188 if (!sdp_attrs[NFC_SDP_ATTR_URI])
1191 uri_len = nla_len(sdp_attrs[NFC_SDP_ATTR_URI]);
1195 uri = nla_data(sdp_attrs[NFC_SDP_ATTR_URI]);
1196 if (uri == NULL || *uri == 0)
1199 tid = local->sdreq_next_tid++;
1201 sdreq = nfc_llcp_build_sdreq_tlv(tid, uri, uri_len);
1202 if (sdreq == NULL) {
1207 tlvs_len += sdreq->tlv_len;
1209 hlist_add_head(&sdreq->node, &sdreq_list);
1212 if (hlist_empty(&sdreq_list)) {
1217 rc = nfc_llcp_send_snl_sdreq(local, &sdreq_list, tlvs_len);
1219 device_unlock(&dev->dev);
1221 nfc_put_device(dev);
1226 static int nfc_genl_fw_download(struct sk_buff *skb, struct genl_info *info)
1228 struct nfc_dev *dev;
1231 char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1];
1233 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || !info->attrs[NFC_ATTR_FIRMWARE_NAME])
1236 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1238 dev = nfc_get_device(idx);
1242 nla_strlcpy(firmware_name, info->attrs[NFC_ATTR_FIRMWARE_NAME],
1243 sizeof(firmware_name));
1245 rc = nfc_fw_download(dev, firmware_name);
1247 nfc_put_device(dev);
1251 int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name,
1254 struct sk_buff *msg;
1257 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
1261 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
1262 NFC_CMD_FW_DOWNLOAD);
1266 if (nla_put_string(msg, NFC_ATTR_FIRMWARE_NAME, firmware_name) ||
1267 nla_put_u32(msg, NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, result) ||
1268 nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx))
1269 goto nla_put_failure;
1271 genlmsg_end(msg, hdr);
1273 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC);
1278 genlmsg_cancel(msg, hdr);
1284 static int nfc_genl_enable_se(struct sk_buff *skb, struct genl_info *info)
1286 struct nfc_dev *dev;
1290 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1291 !info->attrs[NFC_ATTR_SE_INDEX])
1294 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1295 se_idx = nla_get_u32(info->attrs[NFC_ATTR_SE_INDEX]);
1297 dev = nfc_get_device(idx);
1301 rc = nfc_enable_se(dev, se_idx);
1303 nfc_put_device(dev);
1307 static int nfc_genl_disable_se(struct sk_buff *skb, struct genl_info *info)
1309 struct nfc_dev *dev;
1313 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1314 !info->attrs[NFC_ATTR_SE_INDEX])
1317 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1318 se_idx = nla_get_u32(info->attrs[NFC_ATTR_SE_INDEX]);
1320 dev = nfc_get_device(idx);
1324 rc = nfc_disable_se(dev, se_idx);
1326 nfc_put_device(dev);
1330 static int nfc_genl_send_se(struct sk_buff *msg, struct nfc_dev *dev,
1331 u32 portid, u32 seq,
1332 struct netlink_callback *cb,
1336 struct nfc_se *se, *n;
1338 list_for_each_entry_safe(se, n, &dev->secure_elements, list) {
1339 hdr = genlmsg_put(msg, portid, seq, &nfc_genl_family, flags,
1342 goto nla_put_failure;
1345 genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
1347 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) ||
1348 nla_put_u32(msg, NFC_ATTR_SE_INDEX, se->idx) ||
1349 nla_put_u8(msg, NFC_ATTR_SE_TYPE, se->type))
1350 goto nla_put_failure;
1352 genlmsg_end(msg, hdr);
1358 genlmsg_cancel(msg, hdr);
1362 static int nfc_genl_dump_ses(struct sk_buff *skb,
1363 struct netlink_callback *cb)
1365 struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
1366 struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
1367 bool first_call = false;
1371 iter = kmalloc(sizeof(struct class_dev_iter), GFP_KERNEL);
1374 cb->args[0] = (long) iter;
1377 mutex_lock(&nfc_devlist_mutex);
1379 cb->seq = nfc_devlist_generation;
1382 nfc_device_iter_init(iter);
1383 dev = nfc_device_iter_next(iter);
1389 rc = nfc_genl_send_se(skb, dev, NETLINK_CB(cb->skb).portid,
1390 cb->nlh->nlmsg_seq, cb, NLM_F_MULTI);
1394 dev = nfc_device_iter_next(iter);
1397 mutex_unlock(&nfc_devlist_mutex);
1399 cb->args[1] = (long) dev;
1404 static int nfc_genl_dump_ses_done(struct netlink_callback *cb)
1406 struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
1409 nfc_device_iter_exit(iter);
1416 static int nfc_se_io(struct nfc_dev *dev, u32 se_idx,
1417 u8 *apdu, size_t apdu_length,
1418 se_io_cb_t cb, void *cb_context)
1423 pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
1425 device_lock(&dev->dev);
1427 if (!device_is_registered(&dev->dev)) {
1437 if (!dev->ops->se_io) {
1442 se = nfc_find_se(dev, se_idx);
1448 if (se->state != NFC_SE_ENABLED) {
1453 rc = dev->ops->se_io(dev, se_idx, apdu,
1454 apdu_length, cb, cb_context);
1457 device_unlock(&dev->dev);
1466 static void se_io_cb(void *context, u8 *apdu, size_t apdu_len, int err)
1468 struct se_io_ctx *ctx = context;
1469 struct sk_buff *msg;
1472 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1478 hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
1483 if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, ctx->dev_idx) ||
1484 nla_put_u32(msg, NFC_ATTR_SE_INDEX, ctx->se_idx) ||
1485 nla_put(msg, NFC_ATTR_SE_APDU, apdu_len, apdu))
1486 goto nla_put_failure;
1488 genlmsg_end(msg, hdr);
1490 genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL);
1497 genlmsg_cancel(msg, hdr);
1505 static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
1507 struct nfc_dev *dev;
1508 struct se_io_ctx *ctx;
1509 u32 dev_idx, se_idx;
1513 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1514 !info->attrs[NFC_ATTR_SE_INDEX] ||
1515 !info->attrs[NFC_ATTR_SE_APDU])
1518 dev_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1519 se_idx = nla_get_u32(info->attrs[NFC_ATTR_SE_INDEX]);
1521 dev = nfc_get_device(dev_idx);
1525 if (!dev->ops || !dev->ops->se_io)
1528 apdu_len = nla_len(info->attrs[NFC_ATTR_SE_APDU]);
1532 apdu = nla_data(info->attrs[NFC_ATTR_SE_APDU]);
1536 ctx = kzalloc(sizeof(struct se_io_ctx), GFP_KERNEL);
1540 ctx->dev_idx = dev_idx;
1541 ctx->se_idx = se_idx;
1543 return nfc_se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx);
1546 static int nfc_genl_vendor_cmd(struct sk_buff *skb,
1547 struct genl_info *info)
1549 struct nfc_dev *dev;
1550 struct nfc_vendor_cmd *cmd;
1551 u32 dev_idx, vid, subcmd;
1556 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1557 !info->attrs[NFC_ATTR_VENDOR_ID] ||
1558 !info->attrs[NFC_ATTR_VENDOR_SUBCMD])
1561 dev_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1562 vid = nla_get_u32(info->attrs[NFC_ATTR_VENDOR_ID]);
1563 subcmd = nla_get_u32(info->attrs[NFC_ATTR_VENDOR_SUBCMD]);
1565 dev = nfc_get_device(dev_idx);
1566 if (!dev || !dev->vendor_cmds || !dev->n_vendor_cmds)
1569 if (info->attrs[NFC_ATTR_VENDOR_DATA]) {
1570 data = nla_data(info->attrs[NFC_ATTR_VENDOR_DATA]);
1571 data_len = nla_len(info->attrs[NFC_ATTR_VENDOR_DATA]);
1579 for (i = 0; i < dev->n_vendor_cmds; i++) {
1580 cmd = &dev->vendor_cmds[i];
1582 if (cmd->vendor_id != vid || cmd->subcmd != subcmd)
1585 dev->cur_cmd_info = info;
1586 err = cmd->doit(dev, data, data_len);
1587 dev->cur_cmd_info = NULL;
1594 /* message building helper */
1595 static inline void *nfc_hdr_put(struct sk_buff *skb, u32 portid, u32 seq,
1598 /* since there is no private header just add the generic one */
1599 return genlmsg_put(skb, portid, seq, &nfc_genl_family, flags, cmd);
1602 static struct sk_buff *
1603 __nfc_alloc_vendor_cmd_skb(struct nfc_dev *dev, int approxlen,
1604 u32 portid, u32 seq,
1605 enum nfc_attrs attr,
1606 u32 oui, u32 subcmd, gfp_t gfp)
1608 struct sk_buff *skb;
1611 skb = nlmsg_new(approxlen + 100, gfp);
1615 hdr = nfc_hdr_put(skb, portid, seq, 0, NFC_CMD_VENDOR);
1621 if (nla_put_u32(skb, NFC_ATTR_DEVICE_INDEX, dev->idx))
1622 goto nla_put_failure;
1623 if (nla_put_u32(skb, NFC_ATTR_VENDOR_ID, oui))
1624 goto nla_put_failure;
1625 if (nla_put_u32(skb, NFC_ATTR_VENDOR_SUBCMD, subcmd))
1626 goto nla_put_failure;
1628 ((void **)skb->cb)[0] = dev;
1629 ((void **)skb->cb)[1] = hdr;
1638 struct sk_buff *__nfc_alloc_vendor_cmd_reply_skb(struct nfc_dev *dev,
1639 enum nfc_attrs attr,
1640 u32 oui, u32 subcmd,
1643 if (WARN_ON(!dev->cur_cmd_info))
1646 return __nfc_alloc_vendor_cmd_skb(dev, approxlen,
1647 dev->cur_cmd_info->snd_portid,
1648 dev->cur_cmd_info->snd_seq, attr,
1649 oui, subcmd, GFP_KERNEL);
1651 EXPORT_SYMBOL(__nfc_alloc_vendor_cmd_reply_skb);
1653 int nfc_vendor_cmd_reply(struct sk_buff *skb)
1655 struct nfc_dev *dev = ((void **)skb->cb)[0];
1656 void *hdr = ((void **)skb->cb)[1];
1658 /* clear CB data for netlink core to own from now on */
1659 memset(skb->cb, 0, sizeof(skb->cb));
1661 if (WARN_ON(!dev->cur_cmd_info)) {
1666 genlmsg_end(skb, hdr);
1667 return genlmsg_reply(skb, dev->cur_cmd_info);
1669 EXPORT_SYMBOL(nfc_vendor_cmd_reply);
1671 static const struct genl_ops nfc_genl_ops[] = {
1673 .cmd = NFC_CMD_GET_DEVICE,
1674 .doit = nfc_genl_get_device,
1675 .dumpit = nfc_genl_dump_devices,
1676 .done = nfc_genl_dump_devices_done,
1677 .policy = nfc_genl_policy,
1680 .cmd = NFC_CMD_DEV_UP,
1681 .doit = nfc_genl_dev_up,
1682 .policy = nfc_genl_policy,
1685 .cmd = NFC_CMD_DEV_DOWN,
1686 .doit = nfc_genl_dev_down,
1687 .policy = nfc_genl_policy,
1690 .cmd = NFC_CMD_START_POLL,
1691 .doit = nfc_genl_start_poll,
1692 .policy = nfc_genl_policy,
1695 .cmd = NFC_CMD_STOP_POLL,
1696 .doit = nfc_genl_stop_poll,
1697 .policy = nfc_genl_policy,
1700 .cmd = NFC_CMD_DEP_LINK_UP,
1701 .doit = nfc_genl_dep_link_up,
1702 .policy = nfc_genl_policy,
1705 .cmd = NFC_CMD_DEP_LINK_DOWN,
1706 .doit = nfc_genl_dep_link_down,
1707 .policy = nfc_genl_policy,
1710 .cmd = NFC_CMD_GET_TARGET,
1711 .dumpit = nfc_genl_dump_targets,
1712 .done = nfc_genl_dump_targets_done,
1713 .policy = nfc_genl_policy,
1716 .cmd = NFC_CMD_LLC_GET_PARAMS,
1717 .doit = nfc_genl_llc_get_params,
1718 .policy = nfc_genl_policy,
1721 .cmd = NFC_CMD_LLC_SET_PARAMS,
1722 .doit = nfc_genl_llc_set_params,
1723 .policy = nfc_genl_policy,
1726 .cmd = NFC_CMD_LLC_SDREQ,
1727 .doit = nfc_genl_llc_sdreq,
1728 .policy = nfc_genl_policy,
1731 .cmd = NFC_CMD_FW_DOWNLOAD,
1732 .doit = nfc_genl_fw_download,
1733 .policy = nfc_genl_policy,
1736 .cmd = NFC_CMD_ENABLE_SE,
1737 .doit = nfc_genl_enable_se,
1738 .policy = nfc_genl_policy,
1741 .cmd = NFC_CMD_DISABLE_SE,
1742 .doit = nfc_genl_disable_se,
1743 .policy = nfc_genl_policy,
1746 .cmd = NFC_CMD_GET_SE,
1747 .dumpit = nfc_genl_dump_ses,
1748 .done = nfc_genl_dump_ses_done,
1749 .policy = nfc_genl_policy,
1752 .cmd = NFC_CMD_SE_IO,
1753 .doit = nfc_genl_se_io,
1754 .policy = nfc_genl_policy,
1757 .cmd = NFC_CMD_ACTIVATE_TARGET,
1758 .doit = nfc_genl_activate_target,
1759 .policy = nfc_genl_policy,
1762 .cmd = NFC_CMD_VENDOR,
1763 .doit = nfc_genl_vendor_cmd,
1764 .policy = nfc_genl_policy,
1769 struct urelease_work {
1770 struct work_struct w;
1774 static void nfc_urelease_event_work(struct work_struct *work)
1776 struct urelease_work *w = container_of(work, struct urelease_work, w);
1777 struct class_dev_iter iter;
1778 struct nfc_dev *dev;
1780 pr_debug("portid %d\n", w->portid);
1782 mutex_lock(&nfc_devlist_mutex);
1784 nfc_device_iter_init(&iter);
1785 dev = nfc_device_iter_next(&iter);
1788 mutex_lock(&dev->genl_data.genl_data_mutex);
1790 if (dev->genl_data.poll_req_portid == w->portid) {
1792 dev->genl_data.poll_req_portid = 0;
1795 mutex_unlock(&dev->genl_data.genl_data_mutex);
1797 dev = nfc_device_iter_next(&iter);
1800 nfc_device_iter_exit(&iter);
1802 mutex_unlock(&nfc_devlist_mutex);
1807 static int nfc_genl_rcv_nl_event(struct notifier_block *this,
1808 unsigned long event, void *ptr)
1810 struct netlink_notify *n = ptr;
1811 struct urelease_work *w;
1813 if (event != NETLINK_URELEASE || n->protocol != NETLINK_GENERIC)
1816 pr_debug("NETLINK_URELEASE event from id %d\n", n->portid);
1818 w = kmalloc(sizeof(*w), GFP_ATOMIC);
1820 INIT_WORK((struct work_struct *) w, nfc_urelease_event_work);
1821 w->portid = n->portid;
1822 schedule_work((struct work_struct *) w);
1829 void nfc_genl_data_init(struct nfc_genl_data *genl_data)
1831 genl_data->poll_req_portid = 0;
1832 mutex_init(&genl_data->genl_data_mutex);
1835 void nfc_genl_data_exit(struct nfc_genl_data *genl_data)
1837 mutex_destroy(&genl_data->genl_data_mutex);
1840 static struct notifier_block nl_notifier = {
1841 .notifier_call = nfc_genl_rcv_nl_event,
1845 * nfc_genl_init() - Initialize netlink interface
1847 * This initialization function registers the nfc netlink family.
1849 int __init nfc_genl_init(void)
1853 rc = genl_register_family_with_ops_groups(&nfc_genl_family,
1859 netlink_register_notifier(&nl_notifier);
1865 * nfc_genl_exit() - Deinitialize netlink interface
1867 * This exit function unregisters the nfc netlink family.
1869 void nfc_genl_exit(void)
1871 netlink_unregister_notifier(&nl_notifier);
1872 genl_unregister_family(&nfc_genl_family);