2 * Copyright (C) 2011 Instituto Nokia de Tecnologia
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
24 #include <linux/init.h>
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/slab.h>
28 #include <linux/rfkill.h>
29 #include <linux/nfc.h>
31 #include <net/genetlink.h>
37 #define NFC_CHECK_PRES_FREQ_MS 2000
39 int nfc_devlist_generation;
40 DEFINE_MUTEX(nfc_devlist_mutex);
42 /* NFC device ID bitmap */
43 static DEFINE_IDA(nfc_index_ida);
45 int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name)
49 pr_debug("%s do firmware %s\n", dev_name(&dev->dev), firmware_name);
51 device_lock(&dev->dev);
53 if (!device_is_registered(&dev->dev)) {
63 if (!dev->ops->fw_download) {
68 dev->fw_download_in_progress = true;
69 rc = dev->ops->fw_download(dev, firmware_name);
71 dev->fw_download_in_progress = false;
74 device_unlock(&dev->dev);
79 * nfc_fw_download_done - inform that a firmware download was completed
81 * @dev: The nfc device to which firmware was downloaded
82 * @firmware_name: The firmware filename
83 * @result: The positive value of a standard errno value
85 int nfc_fw_download_done(struct nfc_dev *dev, const char *firmware_name,
88 dev->fw_download_in_progress = false;
90 return nfc_genl_fw_download_done(dev, firmware_name, result);
92 EXPORT_SYMBOL(nfc_fw_download_done);
95 * nfc_dev_up - turn on the NFC device
97 * @dev: The nfc device to be turned on
99 * The device remains up until the nfc_dev_down function is called.
101 int nfc_dev_up(struct nfc_dev *dev)
105 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
107 device_lock(&dev->dev);
109 if (dev->rfkill && rfkill_blocked(dev->rfkill)) {
114 if (!device_is_registered(&dev->dev)) {
119 if (dev->fw_download_in_progress) {
129 if (dev->ops->dev_up)
130 rc = dev->ops->dev_up(dev);
135 /* We have to enable the device before discovering SEs */
136 if (dev->ops->discover_se && dev->ops->discover_se(dev))
137 pr_err("SE discovery failed\n");
140 device_unlock(&dev->dev);
145 * nfc_dev_down - turn off the NFC device
147 * @dev: The nfc device to be turned off
149 int nfc_dev_down(struct nfc_dev *dev)
153 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
155 device_lock(&dev->dev);
157 if (!device_is_registered(&dev->dev)) {
167 if (dev->polling || dev->active_target) {
172 if (dev->ops->dev_down)
173 dev->ops->dev_down(dev);
178 device_unlock(&dev->dev);
182 static int nfc_rfkill_set_block(void *data, bool blocked)
184 struct nfc_dev *dev = data;
186 pr_debug("%s blocked %d", dev_name(&dev->dev), blocked);
196 static const struct rfkill_ops nfc_rfkill_ops = {
197 .set_block = nfc_rfkill_set_block,
201 * nfc_start_poll - start polling for nfc targets
203 * @dev: The nfc device that must start polling
204 * @protocols: bitset of nfc protocols that must be used for polling
206 * The device remains polling for targets until a target is found or
207 * the nfc_stop_poll function is called.
209 int nfc_start_poll(struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols)
213 pr_debug("dev_name %s initiator protocols 0x%x target protocols 0x%x\n",
214 dev_name(&dev->dev), im_protocols, tm_protocols);
216 if (!im_protocols && !tm_protocols)
219 device_lock(&dev->dev);
221 if (!device_is_registered(&dev->dev)) {
236 rc = dev->ops->start_poll(dev, im_protocols, tm_protocols);
239 dev->rf_mode = NFC_RF_NONE;
243 device_unlock(&dev->dev);
248 * nfc_stop_poll - stop polling for nfc targets
250 * @dev: The nfc device that must stop polling
252 int nfc_stop_poll(struct nfc_dev *dev)
256 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
258 device_lock(&dev->dev);
260 if (!device_is_registered(&dev->dev)) {
270 dev->ops->stop_poll(dev);
271 dev->polling = false;
272 dev->rf_mode = NFC_RF_NONE;
275 device_unlock(&dev->dev);
279 static struct nfc_target *nfc_find_target(struct nfc_dev *dev, u32 target_idx)
283 if (dev->n_targets == 0)
286 for (i = 0; i < dev->n_targets; i++) {
287 if (dev->targets[i].idx == target_idx)
288 return &dev->targets[i];
294 int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode)
299 struct nfc_target *target;
301 pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode);
303 if (!dev->ops->dep_link_up)
306 device_lock(&dev->dev);
308 if (!device_is_registered(&dev->dev)) {
313 if (dev->dep_link_up == true) {
318 gb = nfc_llcp_general_bytes(dev, &gb_len);
319 if (gb_len > NFC_MAX_GT_LEN) {
324 target = nfc_find_target(dev, target_index);
325 if (target == NULL) {
330 rc = dev->ops->dep_link_up(dev, target, comm_mode, gb, gb_len);
332 dev->active_target = target;
333 dev->rf_mode = NFC_RF_INITIATOR;
337 device_unlock(&dev->dev);
341 int nfc_dep_link_down(struct nfc_dev *dev)
345 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
347 if (!dev->ops->dep_link_down)
350 device_lock(&dev->dev);
352 if (!device_is_registered(&dev->dev)) {
357 if (dev->dep_link_up == false) {
362 rc = dev->ops->dep_link_down(dev);
364 dev->dep_link_up = false;
365 dev->active_target = NULL;
366 dev->rf_mode = NFC_RF_NONE;
367 nfc_llcp_mac_is_down(dev);
368 nfc_genl_dep_link_down_event(dev);
372 device_unlock(&dev->dev);
377 int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
378 u8 comm_mode, u8 rf_mode)
380 dev->dep_link_up = true;
382 if (!dev->active_target && rf_mode == NFC_RF_INITIATOR) {
383 struct nfc_target *target;
385 target = nfc_find_target(dev, target_idx);
389 dev->active_target = target;
392 dev->polling = false;
393 dev->rf_mode = rf_mode;
395 nfc_llcp_mac_is_up(dev, target_idx, comm_mode, rf_mode);
397 return nfc_genl_dep_link_up_event(dev, target_idx, comm_mode, rf_mode);
399 EXPORT_SYMBOL(nfc_dep_link_is_up);
402 * nfc_activate_target - prepare the target for data exchange
404 * @dev: The nfc device that found the target
405 * @target_idx: index of the target that must be activated
406 * @protocol: nfc protocol that will be used for data exchange
408 int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol)
411 struct nfc_target *target;
413 pr_debug("dev_name=%s target_idx=%u protocol=%u\n",
414 dev_name(&dev->dev), target_idx, protocol);
416 device_lock(&dev->dev);
418 if (!device_is_registered(&dev->dev)) {
423 if (dev->active_target) {
428 target = nfc_find_target(dev, target_idx);
429 if (target == NULL) {
434 rc = dev->ops->activate_target(dev, target, protocol);
436 dev->active_target = target;
437 dev->rf_mode = NFC_RF_INITIATOR;
439 if (dev->ops->check_presence && !dev->shutting_down)
440 mod_timer(&dev->check_pres_timer, jiffies +
441 msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
445 device_unlock(&dev->dev);
450 * nfc_deactivate_target - deactivate a nfc target
452 * @dev: The nfc device that found the target
453 * @target_idx: index of the target that must be deactivated
455 int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx)
459 pr_debug("dev_name=%s target_idx=%u\n",
460 dev_name(&dev->dev), target_idx);
462 device_lock(&dev->dev);
464 if (!device_is_registered(&dev->dev)) {
469 if (dev->active_target == NULL) {
474 if (dev->active_target->idx != target_idx) {
479 if (dev->ops->check_presence)
480 del_timer_sync(&dev->check_pres_timer);
482 dev->ops->deactivate_target(dev, dev->active_target);
483 dev->active_target = NULL;
486 device_unlock(&dev->dev);
491 * nfc_data_exchange - transceive data
493 * @dev: The nfc device that found the target
494 * @target_idx: index of the target
495 * @skb: data to be sent
496 * @cb: callback called when the response is received
497 * @cb_context: parameter for the callback function
499 * The user must wait for the callback before calling this function again.
501 int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
502 data_exchange_cb_t cb, void *cb_context)
506 pr_debug("dev_name=%s target_idx=%u skb->len=%u\n",
507 dev_name(&dev->dev), target_idx, skb->len);
509 device_lock(&dev->dev);
511 if (!device_is_registered(&dev->dev)) {
517 if (dev->rf_mode == NFC_RF_INITIATOR && dev->active_target != NULL) {
518 if (dev->active_target->idx != target_idx) {
524 if (dev->ops->check_presence)
525 del_timer_sync(&dev->check_pres_timer);
527 rc = dev->ops->im_transceive(dev, dev->active_target, skb, cb,
530 if (!rc && dev->ops->check_presence && !dev->shutting_down)
531 mod_timer(&dev->check_pres_timer, jiffies +
532 msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
533 } else if (dev->rf_mode == NFC_RF_TARGET && dev->ops->tm_send != NULL) {
534 rc = dev->ops->tm_send(dev, skb);
543 device_unlock(&dev->dev);
547 struct nfc_se *nfc_find_se(struct nfc_dev *dev, u32 se_idx)
549 struct nfc_se *se, *n;
551 list_for_each_entry_safe(se, n, &dev->secure_elements, list)
552 if (se->idx == se_idx)
557 EXPORT_SYMBOL(nfc_find_se);
559 int nfc_enable_se(struct nfc_dev *dev, u32 se_idx)
565 pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
567 device_lock(&dev->dev);
569 if (!device_is_registered(&dev->dev)) {
584 if (!dev->ops->enable_se || !dev->ops->disable_se) {
589 se = nfc_find_se(dev, se_idx);
595 if (se->state == NFC_SE_ENABLED) {
600 rc = dev->ops->enable_se(dev, se_idx);
602 se->state = NFC_SE_ENABLED;
605 device_unlock(&dev->dev);
609 int nfc_disable_se(struct nfc_dev *dev, u32 se_idx)
615 pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
617 device_lock(&dev->dev);
619 if (!device_is_registered(&dev->dev)) {
629 if (!dev->ops->enable_se || !dev->ops->disable_se) {
634 se = nfc_find_se(dev, se_idx);
640 if (se->state == NFC_SE_DISABLED) {
645 rc = dev->ops->disable_se(dev, se_idx);
647 se->state = NFC_SE_DISABLED;
650 device_unlock(&dev->dev);
654 int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
656 pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len);
658 if (gb_len > NFC_MAX_GT_LEN)
661 return nfc_llcp_set_remote_gb(dev, gb, gb_len);
663 EXPORT_SYMBOL(nfc_set_remote_general_bytes);
665 u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, size_t *gb_len)
667 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
669 return nfc_llcp_general_bytes(dev, gb_len);
671 EXPORT_SYMBOL(nfc_get_local_general_bytes);
673 int nfc_tm_data_received(struct nfc_dev *dev, struct sk_buff *skb)
675 /* Only LLCP target mode for now */
676 if (dev->dep_link_up == false) {
681 return nfc_llcp_data_received(dev, skb);
683 EXPORT_SYMBOL(nfc_tm_data_received);
685 int nfc_tm_activated(struct nfc_dev *dev, u32 protocol, u8 comm_mode,
686 u8 *gb, size_t gb_len)
690 device_lock(&dev->dev);
692 dev->polling = false;
695 rc = nfc_set_remote_general_bytes(dev, gb, gb_len);
700 dev->rf_mode = NFC_RF_TARGET;
702 if (protocol == NFC_PROTO_NFC_DEP_MASK)
703 nfc_dep_link_is_up(dev, 0, comm_mode, NFC_RF_TARGET);
705 rc = nfc_genl_tm_activated(dev, protocol);
708 device_unlock(&dev->dev);
712 EXPORT_SYMBOL(nfc_tm_activated);
714 int nfc_tm_deactivated(struct nfc_dev *dev)
716 dev->dep_link_up = false;
717 dev->rf_mode = NFC_RF_NONE;
719 return nfc_genl_tm_deactivated(dev);
721 EXPORT_SYMBOL(nfc_tm_deactivated);
724 * nfc_alloc_send_skb - allocate a skb for data exchange responses
726 * @size: size to allocate
729 struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
730 unsigned int flags, unsigned int size,
734 unsigned int total_size;
737 dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
739 skb = sock_alloc_send_skb(sk, total_size, flags & MSG_DONTWAIT, err);
741 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
747 * nfc_alloc_recv_skb - allocate a skb for data exchange responses
749 * @size: size to allocate
752 struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp)
755 unsigned int total_size;
757 total_size = size + 1;
758 skb = alloc_skb(total_size, gfp);
765 EXPORT_SYMBOL(nfc_alloc_recv_skb);
768 * nfc_targets_found - inform that targets were found
770 * @dev: The nfc device that found the targets
771 * @targets: array of nfc targets found
772 * @ntargets: targets array size
774 * The device driver must call this function when one or many nfc targets
775 * are found. After calling this function, the device driver must stop
776 * polling for targets.
777 * NOTE: This function can be called with targets=NULL and n_targets=0 to
778 * notify a driver error, meaning that the polling operation cannot complete.
779 * IMPORTANT: this function must not be called from an atomic context.
780 * In addition, it must also not be called from a context that would prevent
781 * the NFC Core to call other nfc ops entry point concurrently.
783 int nfc_targets_found(struct nfc_dev *dev,
784 struct nfc_target *targets, int n_targets)
788 pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets);
790 for (i = 0; i < n_targets; i++)
791 targets[i].idx = dev->target_next_idx++;
793 device_lock(&dev->dev);
795 if (dev->polling == false) {
796 device_unlock(&dev->dev);
800 dev->polling = false;
802 dev->targets_generation++;
808 dev->targets = kmemdup(targets,
809 n_targets * sizeof(struct nfc_target),
814 device_unlock(&dev->dev);
819 dev->n_targets = n_targets;
820 device_unlock(&dev->dev);
822 nfc_genl_targets_found(dev);
826 EXPORT_SYMBOL(nfc_targets_found);
829 * nfc_target_lost - inform that an activated target went out of field
831 * @dev: The nfc device that had the activated target in field
832 * @target_idx: the nfc index of the target
834 * The device driver must call this function when the activated target
835 * goes out of the field.
836 * IMPORTANT: this function must not be called from an atomic context.
837 * In addition, it must also not be called from a context that would prevent
838 * the NFC Core to call other nfc ops entry point concurrently.
840 int nfc_target_lost(struct nfc_dev *dev, u32 target_idx)
842 struct nfc_target *tg;
845 pr_debug("dev_name %s n_target %d\n", dev_name(&dev->dev), target_idx);
847 device_lock(&dev->dev);
849 for (i = 0; i < dev->n_targets; i++) {
850 tg = &dev->targets[i];
851 if (tg->idx == target_idx)
855 if (i == dev->n_targets) {
856 device_unlock(&dev->dev);
860 dev->targets_generation++;
862 dev->active_target = NULL;
864 if (dev->n_targets) {
865 memcpy(&dev->targets[i], &dev->targets[i + 1],
866 (dev->n_targets - i) * sizeof(struct nfc_target));
872 device_unlock(&dev->dev);
874 nfc_genl_target_lost(dev, target_idx);
878 EXPORT_SYMBOL(nfc_target_lost);
880 inline void nfc_driver_failure(struct nfc_dev *dev, int err)
882 nfc_targets_found(dev, NULL, 0);
884 EXPORT_SYMBOL(nfc_driver_failure);
886 int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type)
891 pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
893 se = nfc_find_se(dev, se_idx);
897 se = kzalloc(sizeof(struct nfc_se), GFP_KERNEL);
903 se->state = NFC_SE_DISABLED;
904 INIT_LIST_HEAD(&se->list);
906 list_add(&se->list, &dev->secure_elements);
908 rc = nfc_genl_se_added(dev, se_idx, type);
918 EXPORT_SYMBOL(nfc_add_se);
920 int nfc_remove_se(struct nfc_dev *dev, u32 se_idx)
922 struct nfc_se *se, *n;
925 pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
927 list_for_each_entry_safe(se, n, &dev->secure_elements, list)
928 if (se->idx == se_idx) {
929 rc = nfc_genl_se_removed(dev, se_idx);
941 EXPORT_SYMBOL(nfc_remove_se);
943 static void nfc_release(struct device *d)
945 struct nfc_dev *dev = to_nfc_dev(d);
946 struct nfc_se *se, *n;
948 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
950 nfc_genl_data_exit(&dev->genl_data);
953 list_for_each_entry_safe(se, n, &dev->secure_elements, list) {
954 nfc_genl_se_removed(dev, se->idx);
962 static void nfc_check_pres_work(struct work_struct *work)
964 struct nfc_dev *dev = container_of(work, struct nfc_dev,
968 device_lock(&dev->dev);
970 if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) {
971 rc = dev->ops->check_presence(dev, dev->active_target);
972 if (rc == -EOPNOTSUPP)
975 u32 active_target_idx = dev->active_target->idx;
976 device_unlock(&dev->dev);
977 nfc_target_lost(dev, active_target_idx);
981 if (!dev->shutting_down)
982 mod_timer(&dev->check_pres_timer, jiffies +
983 msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
987 device_unlock(&dev->dev);
990 static void nfc_check_pres_timeout(unsigned long data)
992 struct nfc_dev *dev = (struct nfc_dev *)data;
994 schedule_work(&dev->check_pres_work);
997 struct class nfc_class = {
999 .dev_release = nfc_release,
1001 EXPORT_SYMBOL(nfc_class);
1003 static int match_idx(struct device *d, const void *data)
1005 struct nfc_dev *dev = to_nfc_dev(d);
1006 const unsigned int *idx = data;
1008 return dev->idx == *idx;
1011 struct nfc_dev *nfc_get_device(unsigned int idx)
1015 d = class_find_device(&nfc_class, NULL, &idx, match_idx);
1019 return to_nfc_dev(d);
1023 * nfc_allocate_device - allocate a new nfc device
1025 * @ops: device operations
1026 * @supported_protocols: NFC protocols supported by the device
1028 struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
1029 u32 supported_protocols,
1030 int tx_headroom, int tx_tailroom)
1032 struct nfc_dev *dev;
1034 if (!ops->start_poll || !ops->stop_poll || !ops->activate_target ||
1035 !ops->deactivate_target || !ops->im_transceive)
1038 if (!supported_protocols)
1041 dev = kzalloc(sizeof(struct nfc_dev), GFP_KERNEL);
1046 dev->supported_protocols = supported_protocols;
1047 dev->tx_headroom = tx_headroom;
1048 dev->tx_tailroom = tx_tailroom;
1049 INIT_LIST_HEAD(&dev->secure_elements);
1051 nfc_genl_data_init(&dev->genl_data);
1053 dev->rf_mode = NFC_RF_NONE;
1055 /* first generation must not be 0 */
1056 dev->targets_generation = 1;
1058 if (ops->check_presence) {
1059 init_timer(&dev->check_pres_timer);
1060 dev->check_pres_timer.data = (unsigned long)dev;
1061 dev->check_pres_timer.function = nfc_check_pres_timeout;
1063 INIT_WORK(&dev->check_pres_work, nfc_check_pres_work);
1068 EXPORT_SYMBOL(nfc_allocate_device);
1071 * nfc_register_device - register a nfc device in the nfc subsystem
1073 * @dev: The nfc device to register
1075 int nfc_register_device(struct nfc_dev *dev)
1079 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
1081 dev->idx = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL);
1085 dev->dev.class = &nfc_class;
1086 dev_set_name(&dev->dev, "nfc%d", dev->idx);
1087 device_initialize(&dev->dev);
1089 mutex_lock(&nfc_devlist_mutex);
1090 nfc_devlist_generation++;
1091 rc = device_add(&dev->dev);
1092 mutex_unlock(&nfc_devlist_mutex);
1097 rc = nfc_llcp_register_device(dev);
1099 pr_err("Could not register llcp device\n");
1101 rc = nfc_genl_device_added(dev);
1103 pr_debug("The userspace won't be notified that the device %s was added\n",
1104 dev_name(&dev->dev));
1106 dev->rfkill = rfkill_alloc(dev_name(&dev->dev), &dev->dev,
1107 RFKILL_TYPE_NFC, &nfc_rfkill_ops, dev);
1109 if (rfkill_register(dev->rfkill) < 0) {
1110 rfkill_destroy(dev->rfkill);
1117 EXPORT_SYMBOL(nfc_register_device);
1120 * nfc_unregister_device - unregister a nfc device in the nfc subsystem
1122 * @dev: The nfc device to unregister
1124 void nfc_unregister_device(struct nfc_dev *dev)
1128 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
1133 rfkill_unregister(dev->rfkill);
1134 rfkill_destroy(dev->rfkill);
1137 if (dev->ops->check_presence) {
1138 device_lock(&dev->dev);
1139 dev->shutting_down = true;
1140 device_unlock(&dev->dev);
1141 del_timer_sync(&dev->check_pres_timer);
1142 cancel_work_sync(&dev->check_pres_work);
1145 rc = nfc_genl_device_removed(dev);
1147 pr_debug("The userspace won't be notified that the device %s "
1148 "was removed\n", dev_name(&dev->dev));
1150 nfc_llcp_unregister_device(dev);
1152 mutex_lock(&nfc_devlist_mutex);
1153 nfc_devlist_generation++;
1154 device_del(&dev->dev);
1155 mutex_unlock(&nfc_devlist_mutex);
1157 ida_simple_remove(&nfc_index_ida, id);
1159 EXPORT_SYMBOL(nfc_unregister_device);
1161 static int __init nfc_init(void)
1165 pr_info("NFC Core ver %s\n", VERSION);
1167 rc = class_register(&nfc_class);
1171 rc = nfc_genl_init();
1175 /* the first generation must not be 0 */
1176 nfc_devlist_generation = 1;
1178 rc = rawsock_init();
1182 rc = nfc_llcp_init();
1199 class_unregister(&nfc_class);
1203 static void __exit nfc_exit(void)
1209 class_unregister(&nfc_class);
1212 subsys_initcall(nfc_init);
1213 module_exit(nfc_exit);
1216 MODULE_DESCRIPTION("NFC Core ver " VERSION);
1217 MODULE_VERSION(VERSION);
1218 MODULE_LICENSE("GPL");
1219 MODULE_ALIAS_NETPROTO(PF_NFC);
1220 MODULE_ALIAS_GENL_FAMILY(NFC_GENL_NAME);