blob: dacadfbcacea177d01f49b8e5e958c158ddec9f3 [file] [log] [blame]
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -03001/*
2 * Copyright (C) 2011 Instituto Nokia de Tecnologia
3 *
4 * Authors:
5 * Lauro Ramos Venancio <lauro.venancio@openbossa.org>
6 * Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
7 *
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.
12 *
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.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the
20 * Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
Samuel Ortiz52858b52011-12-14 16:43:05 +010024#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
Joe Perchesed1e0ad2011-11-29 11:37:32 -080025
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -030026#include <linux/init.h>
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/slab.h>
Samuel Ortizbe055b22013-04-11 11:52:20 +020030#include <linux/rfkill.h>
Samuel Ortiz7c7cd3b2011-12-14 16:43:06 +010031#include <linux/nfc.h>
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -030032
Samuel Ortiz5df16ca2012-06-12 16:54:16 +020033#include <net/genetlink.h>
34
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -030035#include "nfc.h"
36
37#define VERSION "0.1"
38
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +020039#define NFC_CHECK_PRES_FREQ_MS 2000
40
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -030041int nfc_devlist_generation;
42DEFINE_MUTEX(nfc_devlist_mutex);
43
Samuel Ortiz7eda8b8e92012-10-22 15:57:58 +020044/* NFC device ID bitmap */
45static DEFINE_IDA(nfc_index_ida);
46
Eric Lapuyade9674da82013-04-29 17:13:27 +020047int nfc_fw_upload(struct nfc_dev *dev, const char *firmware_name)
48{
49 int rc = 0;
50
51 pr_debug("%s do firmware %s\n", dev_name(&dev->dev), firmware_name);
52
53 device_lock(&dev->dev);
54
55 if (!device_is_registered(&dev->dev)) {
56 rc = -ENODEV;
57 goto error;
58 }
59
60 if (dev->dev_up) {
61 rc = -EBUSY;
62 goto error;
63 }
64
65 if (!dev->ops->fw_upload) {
66 rc = -EOPNOTSUPP;
67 goto error;
68 }
69
70 dev->fw_upload_in_progress = true;
71 rc = dev->ops->fw_upload(dev, firmware_name);
72 if (rc)
73 dev->fw_upload_in_progress = false;
74
75error:
76 device_unlock(&dev->dev);
77 return rc;
78}
79
80int nfc_fw_upload_done(struct nfc_dev *dev, const char *firmware_name)
81{
82 dev->fw_upload_in_progress = false;
83
84 return nfc_genl_fw_upload_done(dev, firmware_name);
85}
86EXPORT_SYMBOL(nfc_fw_upload_done);
87
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -030088/**
Ilan Elias8b3fe7b2011-09-18 11:19:33 +030089 * nfc_dev_up - turn on the NFC device
90 *
91 * @dev: The nfc device to be turned on
92 *
93 * The device remains up until the nfc_dev_down function is called.
94 */
95int nfc_dev_up(struct nfc_dev *dev)
96{
97 int rc = 0;
98
Joe Perches20c239c2011-11-29 11:37:33 -080099 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
Ilan Elias8b3fe7b2011-09-18 11:19:33 +0300100
101 device_lock(&dev->dev);
102
Samuel Ortizbe055b22013-04-11 11:52:20 +0200103 if (dev->rfkill && rfkill_blocked(dev->rfkill)) {
104 rc = -ERFKILL;
105 goto error;
106 }
107
Ilan Elias8b3fe7b2011-09-18 11:19:33 +0300108 if (!device_is_registered(&dev->dev)) {
109 rc = -ENODEV;
110 goto error;
111 }
112
Eric Lapuyade9674da82013-04-29 17:13:27 +0200113 if (dev->fw_upload_in_progress) {
114 rc = -EBUSY;
115 goto error;
116 }
117
Ilan Elias8b3fe7b2011-09-18 11:19:33 +0300118 if (dev->dev_up) {
119 rc = -EALREADY;
120 goto error;
121 }
122
123 if (dev->ops->dev_up)
124 rc = dev->ops->dev_up(dev);
125
126 if (!rc)
127 dev->dev_up = true;
128
Samuel Ortiz0a946302013-05-10 11:57:06 +0200129 /* We have to enable the device before discovering SEs */
130 if (dev->ops->discover_se) {
131 rc = dev->ops->discover_se(dev);
132 if (!rc)
133 pr_warn("SE discovery failed\n");
134 }
135
Ilan Elias8b3fe7b2011-09-18 11:19:33 +0300136error:
137 device_unlock(&dev->dev);
138 return rc;
139}
140
141/**
142 * nfc_dev_down - turn off the NFC device
143 *
144 * @dev: The nfc device to be turned off
145 */
146int nfc_dev_down(struct nfc_dev *dev)
147{
148 int rc = 0;
149
Joe Perches20c239c2011-11-29 11:37:33 -0800150 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
Ilan Elias8b3fe7b2011-09-18 11:19:33 +0300151
152 device_lock(&dev->dev);
153
154 if (!device_is_registered(&dev->dev)) {
155 rc = -ENODEV;
156 goto error;
157 }
158
159 if (!dev->dev_up) {
160 rc = -EALREADY;
161 goto error;
162 }
163
Eric Lapuyade90099432012-05-07 12:31:13 +0200164 if (dev->polling || dev->active_target) {
Ilan Elias8b3fe7b2011-09-18 11:19:33 +0300165 rc = -EBUSY;
166 goto error;
167 }
168
169 if (dev->ops->dev_down)
170 dev->ops->dev_down(dev);
171
172 dev->dev_up = false;
173
174error:
175 device_unlock(&dev->dev);
176 return rc;
177}
178
Samuel Ortizbe055b22013-04-11 11:52:20 +0200179static int nfc_rfkill_set_block(void *data, bool blocked)
180{
181 struct nfc_dev *dev = data;
182
183 pr_debug("%s blocked %d", dev_name(&dev->dev), blocked);
184
185 if (!blocked)
186 return 0;
187
188 nfc_dev_down(dev);
189
190 return 0;
191}
192
193static const struct rfkill_ops nfc_rfkill_ops = {
194 .set_block = nfc_rfkill_set_block,
195};
196
Ilan Elias8b3fe7b2011-09-18 11:19:33 +0300197/**
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300198 * nfc_start_poll - start polling for nfc targets
199 *
200 * @dev: The nfc device that must start polling
201 * @protocols: bitset of nfc protocols that must be used for polling
202 *
203 * The device remains polling for targets until a target is found or
204 * the nfc_stop_poll function is called.
205 */
Samuel Ortizfe7c5802012-05-15 15:57:06 +0200206int nfc_start_poll(struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols)
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300207{
208 int rc;
209
Samuel Ortizfe7c5802012-05-15 15:57:06 +0200210 pr_debug("dev_name %s initiator protocols 0x%x target protocols 0x%x\n",
211 dev_name(&dev->dev), im_protocols, tm_protocols);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300212
Samuel Ortizfe7c5802012-05-15 15:57:06 +0200213 if (!im_protocols && !tm_protocols)
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300214 return -EINVAL;
215
216 device_lock(&dev->dev);
217
218 if (!device_is_registered(&dev->dev)) {
219 rc = -ENODEV;
220 goto error;
221 }
222
Samuel Ortiz7757dc82013-04-10 12:25:30 +0200223 if (!dev->dev_up) {
224 rc = -ENODEV;
225 goto error;
226 }
227
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300228 if (dev->polling) {
229 rc = -EBUSY;
230 goto error;
231 }
232
Samuel Ortizfe7c5802012-05-15 15:57:06 +0200233 rc = dev->ops->start_poll(dev, im_protocols, tm_protocols);
Samuel Ortizf212ad52012-05-31 00:02:26 +0200234 if (!rc) {
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300235 dev->polling = true;
Samuel Ortizf212ad52012-05-31 00:02:26 +0200236 dev->rf_mode = NFC_RF_NONE;
237 }
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300238
239error:
240 device_unlock(&dev->dev);
241 return rc;
242}
243
244/**
245 * nfc_stop_poll - stop polling for nfc targets
246 *
247 * @dev: The nfc device that must stop polling
248 */
249int nfc_stop_poll(struct nfc_dev *dev)
250{
251 int rc = 0;
252
Joe Perches20c239c2011-11-29 11:37:33 -0800253 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300254
255 device_lock(&dev->dev);
256
257 if (!device_is_registered(&dev->dev)) {
258 rc = -ENODEV;
259 goto error;
260 }
261
262 if (!dev->polling) {
263 rc = -EINVAL;
264 goto error;
265 }
266
267 dev->ops->stop_poll(dev);
268 dev->polling = false;
Thierry Escande5bcf0992012-10-05 11:05:45 +0200269 dev->rf_mode = NFC_RF_NONE;
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300270
271error:
272 device_unlock(&dev->dev);
273 return rc;
274}
275
Eric Lapuyade90099432012-05-07 12:31:13 +0200276static struct nfc_target *nfc_find_target(struct nfc_dev *dev, u32 target_idx)
277{
278 int i;
279
280 if (dev->n_targets == 0)
281 return NULL;
282
Szymon Janc0f450772012-10-17 15:23:39 +0200283 for (i = 0; i < dev->n_targets; i++) {
Eric Lapuyade90099432012-05-07 12:31:13 +0200284 if (dev->targets[i].idx == target_idx)
285 return &dev->targets[i];
286 }
287
288 return NULL;
289}
290
Samuel Ortiz47807d32012-03-05 01:03:50 +0100291int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode)
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100292{
293 int rc = 0;
Samuel Ortiz47807d32012-03-05 01:03:50 +0100294 u8 *gb;
295 size_t gb_len;
Eric Lapuyade90099432012-05-07 12:31:13 +0200296 struct nfc_target *target;
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100297
Samuel Ortiz47807d32012-03-05 01:03:50 +0100298 pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode);
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100299
300 if (!dev->ops->dep_link_up)
301 return -EOPNOTSUPP;
302
303 device_lock(&dev->dev);
304
305 if (!device_is_registered(&dev->dev)) {
306 rc = -ENODEV;
307 goto error;
308 }
309
310 if (dev->dep_link_up == true) {
311 rc = -EALREADY;
312 goto error;
313 }
314
Samuel Ortiz47807d32012-03-05 01:03:50 +0100315 gb = nfc_llcp_general_bytes(dev, &gb_len);
316 if (gb_len > NFC_MAX_GT_LEN) {
317 rc = -EINVAL;
318 goto error;
319 }
320
Eric Lapuyade90099432012-05-07 12:31:13 +0200321 target = nfc_find_target(dev, target_index);
322 if (target == NULL) {
323 rc = -ENOTCONN;
324 goto error;
325 }
326
327 rc = dev->ops->dep_link_up(dev, target, comm_mode, gb, gb_len);
Samuel Ortizf212ad52012-05-31 00:02:26 +0200328 if (!rc) {
Eric Lapuyade90099432012-05-07 12:31:13 +0200329 dev->active_target = target;
Samuel Ortizf212ad52012-05-31 00:02:26 +0200330 dev->rf_mode = NFC_RF_INITIATOR;
331 }
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100332
333error:
334 device_unlock(&dev->dev);
335 return rc;
336}
337
338int nfc_dep_link_down(struct nfc_dev *dev)
339{
340 int rc = 0;
341
342 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
343
344 if (!dev->ops->dep_link_down)
345 return -EOPNOTSUPP;
346
347 device_lock(&dev->dev);
348
349 if (!device_is_registered(&dev->dev)) {
350 rc = -ENODEV;
351 goto error;
352 }
353
354 if (dev->dep_link_up == false) {
355 rc = -EALREADY;
356 goto error;
357 }
358
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100359 rc = dev->ops->dep_link_down(dev);
360 if (!rc) {
361 dev->dep_link_up = false;
Eric Lapuyade90099432012-05-07 12:31:13 +0200362 dev->active_target = NULL;
Thierry Escande5bcf0992012-10-05 11:05:45 +0200363 dev->rf_mode = NFC_RF_NONE;
Samuel Ortizd6469602011-12-14 16:43:12 +0100364 nfc_llcp_mac_is_down(dev);
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100365 nfc_genl_dep_link_down_event(dev);
366 }
367
368error:
369 device_unlock(&dev->dev);
Thierry Escande5bcf0992012-10-05 11:05:45 +0200370
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100371 return rc;
372}
373
374int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
Samuel Ortiz0a40acb2012-03-05 01:03:53 +0100375 u8 comm_mode, u8 rf_mode)
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100376{
377 dev->dep_link_up = true;
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100378
Samuel Ortizd6469602011-12-14 16:43:12 +0100379 nfc_llcp_mac_is_up(dev, target_idx, comm_mode, rf_mode);
380
Samuel Ortiz1ed28f62011-12-14 16:43:09 +0100381 return nfc_genl_dep_link_up_event(dev, target_idx, comm_mode, rf_mode);
382}
383EXPORT_SYMBOL(nfc_dep_link_is_up);
384
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300385/**
386 * nfc_activate_target - prepare the target for data exchange
387 *
388 * @dev: The nfc device that found the target
389 * @target_idx: index of the target that must be activated
390 * @protocol: nfc protocol that will be used for data exchange
391 */
392int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol)
393{
394 int rc;
Eric Lapuyade90099432012-05-07 12:31:13 +0200395 struct nfc_target *target;
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300396
Joe Perches20c239c2011-11-29 11:37:33 -0800397 pr_debug("dev_name=%s target_idx=%u protocol=%u\n",
398 dev_name(&dev->dev), target_idx, protocol);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300399
400 device_lock(&dev->dev);
401
402 if (!device_is_registered(&dev->dev)) {
403 rc = -ENODEV;
404 goto error;
405 }
406
Eric Lapuyade90099432012-05-07 12:31:13 +0200407 if (dev->active_target) {
408 rc = -EBUSY;
409 goto error;
410 }
411
412 target = nfc_find_target(dev, target_idx);
413 if (target == NULL) {
414 rc = -ENOTCONN;
415 goto error;
416 }
417
418 rc = dev->ops->activate_target(dev, target, protocol);
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200419 if (!rc) {
Eric Lapuyade90099432012-05-07 12:31:13 +0200420 dev->active_target = target;
Samuel Ortizf212ad52012-05-31 00:02:26 +0200421 dev->rf_mode = NFC_RF_INITIATOR;
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300422
Eric Lapuyadef0c91032012-11-26 18:06:27 +0100423 if (dev->ops->check_presence && !dev->shutting_down)
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200424 mod_timer(&dev->check_pres_timer, jiffies +
425 msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
426 }
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300427
428error:
429 device_unlock(&dev->dev);
430 return rc;
431}
432
433/**
434 * nfc_deactivate_target - deactivate a nfc target
435 *
436 * @dev: The nfc device that found the target
437 * @target_idx: index of the target that must be deactivated
438 */
439int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx)
440{
441 int rc = 0;
442
Joe Perches20c239c2011-11-29 11:37:33 -0800443 pr_debug("dev_name=%s target_idx=%u\n",
444 dev_name(&dev->dev), target_idx);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300445
446 device_lock(&dev->dev);
447
448 if (!device_is_registered(&dev->dev)) {
449 rc = -ENODEV;
450 goto error;
451 }
452
Eric Lapuyade90099432012-05-07 12:31:13 +0200453 if (dev->active_target == NULL) {
454 rc = -ENOTCONN;
455 goto error;
456 }
457
458 if (dev->active_target->idx != target_idx) {
459 rc = -ENOTCONN;
460 goto error;
461 }
462
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200463 if (dev->ops->check_presence)
464 del_timer_sync(&dev->check_pres_timer);
465
Eric Lapuyade90099432012-05-07 12:31:13 +0200466 dev->ops->deactivate_target(dev, dev->active_target);
467 dev->active_target = NULL;
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300468
469error:
470 device_unlock(&dev->dev);
471 return rc;
472}
473
474/**
475 * nfc_data_exchange - transceive data
476 *
477 * @dev: The nfc device that found the target
478 * @target_idx: index of the target
479 * @skb: data to be sent
480 * @cb: callback called when the response is received
481 * @cb_context: parameter for the callback function
482 *
483 * The user must wait for the callback before calling this function again.
484 */
Samuel Ortiz0a40acb2012-03-05 01:03:53 +0100485int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
486 data_exchange_cb_t cb, void *cb_context)
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300487{
488 int rc;
489
Joe Perches20c239c2011-11-29 11:37:33 -0800490 pr_debug("dev_name=%s target_idx=%u skb->len=%u\n",
491 dev_name(&dev->dev), target_idx, skb->len);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300492
493 device_lock(&dev->dev);
494
495 if (!device_is_registered(&dev->dev)) {
496 rc = -ENODEV;
497 kfree_skb(skb);
498 goto error;
499 }
500
Samuel Ortizbe9ae4c2012-05-16 15:55:48 +0200501 if (dev->rf_mode == NFC_RF_INITIATOR && dev->active_target != NULL) {
502 if (dev->active_target->idx != target_idx) {
503 rc = -EADDRNOTAVAIL;
504 kfree_skb(skb);
505 goto error;
506 }
507
508 if (dev->ops->check_presence)
509 del_timer_sync(&dev->check_pres_timer);
510
511 rc = dev->ops->im_transceive(dev, dev->active_target, skb, cb,
512 cb_context);
513
Eric Lapuyadef0c91032012-11-26 18:06:27 +0100514 if (!rc && dev->ops->check_presence && !dev->shutting_down)
Samuel Ortizbe9ae4c2012-05-16 15:55:48 +0200515 mod_timer(&dev->check_pres_timer, jiffies +
516 msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
517 } else if (dev->rf_mode == NFC_RF_TARGET && dev->ops->tm_send != NULL) {
518 rc = dev->ops->tm_send(dev, skb);
519 } else {
Eric Lapuyade144612c2012-04-10 19:43:11 +0200520 rc = -ENOTCONN;
521 kfree_skb(skb);
522 goto error;
523 }
524
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200525
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300526error:
527 device_unlock(&dev->dev);
528 return rc;
529}
530
Samuel Ortiz541d9202011-12-14 16:43:10 +0100531int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
532{
Samuel Ortiz0a40acb2012-03-05 01:03:53 +0100533 pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len);
Samuel Ortiz541d9202011-12-14 16:43:10 +0100534
535 if (gb_len > NFC_MAX_GT_LEN)
536 return -EINVAL;
537
Samuel Ortizd6469602011-12-14 16:43:12 +0100538 return nfc_llcp_set_remote_gb(dev, gb, gb_len);
Samuel Ortiz541d9202011-12-14 16:43:10 +0100539}
540EXPORT_SYMBOL(nfc_set_remote_general_bytes);
541
Samuel Ortizab73b752012-04-10 12:51:52 +0200542u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, size_t *gb_len)
543{
544 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
545
546 return nfc_llcp_general_bytes(dev, gb_len);
547}
548EXPORT_SYMBOL(nfc_get_local_general_bytes);
549
Samuel Ortiz73167ce2012-05-31 00:05:50 +0200550int nfc_tm_data_received(struct nfc_dev *dev, struct sk_buff *skb)
551{
552 /* Only LLCP target mode for now */
553 if (dev->dep_link_up == false) {
554 kfree_skb(skb);
555 return -ENOLINK;
556 }
557
558 return nfc_llcp_data_received(dev, skb);
559}
560EXPORT_SYMBOL(nfc_tm_data_received);
561
Samuel Ortizfc40a8c2012-06-01 13:21:13 +0200562int nfc_tm_activated(struct nfc_dev *dev, u32 protocol, u8 comm_mode,
563 u8 *gb, size_t gb_len)
564{
565 int rc;
566
567 device_lock(&dev->dev);
568
569 dev->polling = false;
570
571 if (gb != NULL) {
572 rc = nfc_set_remote_general_bytes(dev, gb, gb_len);
573 if (rc < 0)
574 goto out;
575 }
576
Samuel Ortizf212ad52012-05-31 00:02:26 +0200577 dev->rf_mode = NFC_RF_TARGET;
578
Samuel Ortizfc40a8c2012-06-01 13:21:13 +0200579 if (protocol == NFC_PROTO_NFC_DEP_MASK)
580 nfc_dep_link_is_up(dev, 0, comm_mode, NFC_RF_TARGET);
581
582 rc = nfc_genl_tm_activated(dev, protocol);
583
584out:
585 device_unlock(&dev->dev);
586
587 return rc;
588}
589EXPORT_SYMBOL(nfc_tm_activated);
590
591int nfc_tm_deactivated(struct nfc_dev *dev)
592{
593 dev->dep_link_up = false;
Thierry Escande5bcf0992012-10-05 11:05:45 +0200594 dev->rf_mode = NFC_RF_NONE;
Samuel Ortizfc40a8c2012-06-01 13:21:13 +0200595
596 return nfc_genl_tm_deactivated(dev);
597}
598EXPORT_SYMBOL(nfc_tm_deactivated);
599
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300600/**
Samuel Ortiz7c7cd3b2011-12-14 16:43:06 +0100601 * nfc_alloc_send_skb - allocate a skb for data exchange responses
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300602 *
603 * @size: size to allocate
604 * @gfp: gfp flags
605 */
Samuel Ortiz7c7cd3b2011-12-14 16:43:06 +0100606struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
Samuel Ortiz0a40acb2012-03-05 01:03:53 +0100607 unsigned int flags, unsigned int size,
608 unsigned int *err)
Samuel Ortiz7c7cd3b2011-12-14 16:43:06 +0100609{
610 struct sk_buff *skb;
611 unsigned int total_size;
612
613 total_size = size +
614 dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE;
615
616 skb = sock_alloc_send_skb(sk, total_size, flags & MSG_DONTWAIT, err);
617 if (skb)
618 skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE);
619
620 return skb;
621}
622
623/**
624 * nfc_alloc_recv_skb - allocate a skb for data exchange responses
625 *
626 * @size: size to allocate
627 * @gfp: gfp flags
628 */
629struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp)
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300630{
631 struct sk_buff *skb;
632 unsigned int total_size;
633
634 total_size = size + 1;
635 skb = alloc_skb(total_size, gfp);
636
637 if (skb)
638 skb_reserve(skb, 1);
639
640 return skb;
641}
Samuel Ortiz7c7cd3b2011-12-14 16:43:06 +0100642EXPORT_SYMBOL(nfc_alloc_recv_skb);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300643
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300644/**
645 * nfc_targets_found - inform that targets were found
646 *
647 * @dev: The nfc device that found the targets
648 * @targets: array of nfc targets found
649 * @ntargets: targets array size
650 *
651 * The device driver must call this function when one or many nfc targets
652 * are found. After calling this function, the device driver must stop
653 * polling for targets.
Eric Lapuyaded94f9c52012-05-03 16:33:32 +0200654 * NOTE: This function can be called with targets=NULL and n_targets=0 to
655 * notify a driver error, meaning that the polling operation cannot complete.
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200656 * IMPORTANT: this function must not be called from an atomic context.
657 * In addition, it must also not be called from a context that would prevent
658 * the NFC Core to call other nfc ops entry point concurrently.
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300659 */
Samuel Ortiz0a40acb2012-03-05 01:03:53 +0100660int nfc_targets_found(struct nfc_dev *dev,
661 struct nfc_target *targets, int n_targets)
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300662{
Samuel Ortizc4fbb652012-04-10 19:43:09 +0200663 int i;
664
Joe Perches20c239c2011-11-29 11:37:33 -0800665 pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets);
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300666
Samuel Ortizc4fbb652012-04-10 19:43:09 +0200667 for (i = 0; i < n_targets; i++)
Eric Lapuyade01ae0ee2012-04-10 19:43:10 +0200668 targets[i].idx = dev->target_next_idx++;
Samuel Ortizc4fbb652012-04-10 19:43:09 +0200669
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200670 device_lock(&dev->dev);
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300671
Eric Lapuyade8668fdd2012-05-03 16:21:58 +0200672 if (dev->polling == false) {
673 device_unlock(&dev->dev);
674 return 0;
675 }
676
677 dev->polling = false;
678
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300679 dev->targets_generation++;
680
681 kfree(dev->targets);
Eric Lapuyaded94f9c52012-05-03 16:33:32 +0200682 dev->targets = NULL;
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300683
Eric Lapuyaded94f9c52012-05-03 16:33:32 +0200684 if (targets) {
685 dev->targets = kmemdup(targets,
686 n_targets * sizeof(struct nfc_target),
687 GFP_ATOMIC);
688
689 if (!dev->targets) {
690 dev->n_targets = 0;
691 device_unlock(&dev->dev);
692 return -ENOMEM;
693 }
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300694 }
695
696 dev->n_targets = n_targets;
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200697 device_unlock(&dev->dev);
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300698
699 nfc_genl_targets_found(dev);
700
701 return 0;
702}
703EXPORT_SYMBOL(nfc_targets_found);
704
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200705/**
706 * nfc_target_lost - inform that an activated target went out of field
707 *
708 * @dev: The nfc device that had the activated target in field
709 * @target_idx: the nfc index of the target
710 *
711 * The device driver must call this function when the activated target
712 * goes out of the field.
713 * IMPORTANT: this function must not be called from an atomic context.
714 * In addition, it must also not be called from a context that would prevent
715 * the NFC Core to call other nfc ops entry point concurrently.
716 */
Eric Lapuyadee1da0ef2012-04-10 19:43:05 +0200717int nfc_target_lost(struct nfc_dev *dev, u32 target_idx)
718{
719 struct nfc_target *tg;
720 int i;
721
722 pr_debug("dev_name %s n_target %d\n", dev_name(&dev->dev), target_idx);
723
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200724 device_lock(&dev->dev);
Eric Lapuyadee1da0ef2012-04-10 19:43:05 +0200725
726 for (i = 0; i < dev->n_targets; i++) {
727 tg = &dev->targets[i];
728 if (tg->idx == target_idx)
729 break;
730 }
731
732 if (i == dev->n_targets) {
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200733 device_unlock(&dev->dev);
Eric Lapuyadee1da0ef2012-04-10 19:43:05 +0200734 return -EINVAL;
735 }
736
737 dev->targets_generation++;
738 dev->n_targets--;
Eric Lapuyade90099432012-05-07 12:31:13 +0200739 dev->active_target = NULL;
Eric Lapuyadee1da0ef2012-04-10 19:43:05 +0200740
741 if (dev->n_targets) {
742 memcpy(&dev->targets[i], &dev->targets[i + 1],
743 (dev->n_targets - i) * sizeof(struct nfc_target));
744 } else {
745 kfree(dev->targets);
746 dev->targets = NULL;
747 }
748
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200749 device_unlock(&dev->dev);
Eric Lapuyadee1da0ef2012-04-10 19:43:05 +0200750
751 nfc_genl_target_lost(dev, target_idx);
752
753 return 0;
754}
755EXPORT_SYMBOL(nfc_target_lost);
756
Eric Lapuyade9eb334a2012-06-11 15:52:38 +0200757inline void nfc_driver_failure(struct nfc_dev *dev, int err)
Eric Lapuyade456411c2012-06-11 13:49:51 +0200758{
Eric Lapuyade9eb334a2012-06-11 15:52:38 +0200759 nfc_targets_found(dev, NULL, 0);
Eric Lapuyade456411c2012-06-11 13:49:51 +0200760}
761EXPORT_SYMBOL(nfc_driver_failure);
762
Samuel Ortizfed7c252013-05-10 15:28:38 +0200763int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type)
764{
765 struct nfc_se *se, *n;
766
767 pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
768
769 list_for_each_entry_safe(se, n, &dev->secure_elements, list)
770 if (se->idx == se_idx)
771 return -EALREADY;
772
773 se = kzalloc(sizeof(struct nfc_se), GFP_KERNEL);
774 if (!se)
775 return -ENOMEM;
776
777 se->idx = se_idx;
778 se->type = type;
779 se->state = NFC_SE_DISABLED;
780 INIT_LIST_HEAD(&se->list);
781
782 list_add(&se->list, &dev->secure_elements);
783
784 return 0;
785}
786EXPORT_SYMBOL(nfc_add_se);
787
788int nfc_remove_se(struct nfc_dev *dev, u32 se_idx)
789{
790 struct nfc_se *se, *n;
791
792 pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx);
793
794 list_for_each_entry_safe(se, n, &dev->secure_elements, list)
795 if (se->idx == se_idx) {
796 list_del(&se->list);
797 kfree(se);
798
799 return 0;
800 }
801
802 return -EINVAL;
803}
804EXPORT_SYMBOL(nfc_remove_se);
805
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300806static void nfc_release(struct device *d)
807{
808 struct nfc_dev *dev = to_nfc_dev(d);
809
Joe Perches20c239c2011-11-29 11:37:33 -0800810 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300811
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300812 nfc_genl_data_exit(&dev->genl_data);
813 kfree(dev->targets);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300814 kfree(dev);
815}
816
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200817static void nfc_check_pres_work(struct work_struct *work)
818{
819 struct nfc_dev *dev = container_of(work, struct nfc_dev,
820 check_pres_work);
821 int rc;
822
823 device_lock(&dev->dev);
824
Eric Lapuyade90099432012-05-07 12:31:13 +0200825 if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) {
826 rc = dev->ops->check_presence(dev, dev->active_target);
Eric Lapuyade632c0162012-10-02 17:27:36 +0200827 if (rc == -EOPNOTSUPP)
828 goto exit;
Eric Lapuyadef0c91032012-11-26 18:06:27 +0100829 if (rc) {
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200830 u32 active_target_idx = dev->active_target->idx;
831 device_unlock(&dev->dev);
832 nfc_target_lost(dev, active_target_idx);
833 return;
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200834 }
Eric Lapuyadef0c91032012-11-26 18:06:27 +0100835
836 if (!dev->shutting_down)
837 mod_timer(&dev->check_pres_timer, jiffies +
838 msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200839 }
840
Eric Lapuyade632c0162012-10-02 17:27:36 +0200841exit:
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200842 device_unlock(&dev->dev);
843}
844
845static void nfc_check_pres_timeout(unsigned long data)
846{
847 struct nfc_dev *dev = (struct nfc_dev *)data;
848
Linus Torvalds916082b2012-10-02 16:01:31 -0700849 schedule_work(&dev->check_pres_work);
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200850}
851
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300852struct class nfc_class = {
853 .name = "nfc",
854 .dev_release = nfc_release,
855};
856EXPORT_SYMBOL(nfc_class);
857
Michał Mirosław9f3b7952013-02-01 20:40:17 +0100858static int match_idx(struct device *d, const void *data)
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300859{
860 struct nfc_dev *dev = to_nfc_dev(d);
Michał Mirosław9f3b7952013-02-01 20:40:17 +0100861 const unsigned int *idx = data;
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300862
863 return dev->idx == *idx;
864}
865
Eric Dumazet95c96172012-04-15 05:58:06 +0000866struct nfc_dev *nfc_get_device(unsigned int idx)
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300867{
868 struct device *d;
869
870 d = class_find_device(&nfc_class, NULL, &idx, match_idx);
871 if (!d)
872 return NULL;
873
874 return to_nfc_dev(d);
875}
876
877/**
878 * nfc_allocate_device - allocate a new nfc device
879 *
880 * @ops: device operations
881 * @supported_protocols: NFC protocols supported by the device
882 */
883struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
Samuel Ortiz0a40acb2012-03-05 01:03:53 +0100884 u32 supported_protocols,
885 int tx_headroom, int tx_tailroom)
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300886{
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300887 struct nfc_dev *dev;
888
889 if (!ops->start_poll || !ops->stop_poll || !ops->activate_target ||
Samuel Ortizbe9ae4c2012-05-16 15:55:48 +0200890 !ops->deactivate_target || !ops->im_transceive)
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300891 return NULL;
892
893 if (!supported_protocols)
894 return NULL;
895
896 dev = kzalloc(sizeof(struct nfc_dev), GFP_KERNEL);
897 if (!dev)
898 return NULL;
899
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300900 dev->ops = ops;
901 dev->supported_protocols = supported_protocols;
Samuel Ortize8753042011-08-19 15:47:11 +0200902 dev->tx_headroom = tx_headroom;
903 dev->tx_tailroom = tx_tailroom;
Samuel Ortizfed7c252013-05-10 15:28:38 +0200904 INIT_LIST_HEAD(&dev->secure_elements);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300905
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300906 nfc_genl_data_init(&dev->genl_data);
907
Thierry Escande5bcf0992012-10-05 11:05:45 +0200908 dev->rf_mode = NFC_RF_NONE;
Eric Lapuyaded4ccb132012-05-07 12:31:15 +0200909
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300910 /* first generation must not be 0 */
911 dev->targets_generation = 1;
912
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200913 if (ops->check_presence) {
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200914 init_timer(&dev->check_pres_timer);
915 dev->check_pres_timer.data = (unsigned long)dev;
916 dev->check_pres_timer.function = nfc_check_pres_timeout;
917
918 INIT_WORK(&dev->check_pres_work, nfc_check_pres_work);
Eric Lapuyadec8d56ae2012-04-10 19:43:12 +0200919 }
920
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300921 return dev;
922}
923EXPORT_SYMBOL(nfc_allocate_device);
924
925/**
926 * nfc_register_device - register a nfc device in the nfc subsystem
927 *
928 * @dev: The nfc device to register
929 */
930int nfc_register_device(struct nfc_dev *dev)
931{
932 int rc;
933
Joe Perches20c239c2011-11-29 11:37:33 -0800934 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300935
Samuel Ortiz7eda8b8e92012-10-22 15:57:58 +0200936 dev->idx = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL);
937 if (dev->idx < 0)
938 return dev->idx;
939
940 dev->dev.class = &nfc_class;
941 dev_set_name(&dev->dev, "nfc%d", dev->idx);
942 device_initialize(&dev->dev);
943
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300944 mutex_lock(&nfc_devlist_mutex);
945 nfc_devlist_generation++;
946 rc = device_add(&dev->dev);
947 mutex_unlock(&nfc_devlist_mutex);
948
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300949 if (rc < 0)
950 return rc;
951
Samuel Ortizd6469602011-12-14 16:43:12 +0100952 rc = nfc_llcp_register_device(dev);
953 if (rc)
954 pr_err("Could not register llcp device\n");
955
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300956 rc = nfc_genl_device_added(dev);
957 if (rc)
Joe Perches20c239c2011-11-29 11:37:33 -0800958 pr_debug("The userspace won't be notified that the device %s was added\n",
959 dev_name(&dev->dev));
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300960
Samuel Ortizbe055b22013-04-11 11:52:20 +0200961 dev->rfkill = rfkill_alloc(dev_name(&dev->dev), &dev->dev,
962 RFKILL_TYPE_NFC, &nfc_rfkill_ops, dev);
963 if (dev->rfkill) {
964 if (rfkill_register(dev->rfkill) < 0) {
965 rfkill_destroy(dev->rfkill);
966 dev->rfkill = NULL;
967 }
968 }
969
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300970 return 0;
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300971}
972EXPORT_SYMBOL(nfc_register_device);
973
974/**
975 * nfc_unregister_device - unregister a nfc device in the nfc subsystem
976 *
977 * @dev: The nfc device to unregister
978 */
979void nfc_unregister_device(struct nfc_dev *dev)
980{
Samuel Ortiz7eda8b8e92012-10-22 15:57:58 +0200981 int rc, id;
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -0300982
Joe Perches20c239c2011-11-29 11:37:33 -0800983 pr_debug("dev_name=%s\n", dev_name(&dev->dev));
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -0300984
Samuel Ortiz7eda8b8e92012-10-22 15:57:58 +0200985 id = dev->idx;
986
Samuel Ortizbe055b22013-04-11 11:52:20 +0200987 if (dev->rfkill) {
988 rfkill_unregister(dev->rfkill);
989 rfkill_destroy(dev->rfkill);
990 }
991
Eric Lapuyadef0c91032012-11-26 18:06:27 +0100992 if (dev->ops->check_presence) {
993 device_lock(&dev->dev);
994 dev->shutting_down = true;
995 device_unlock(&dev->dev);
996 del_timer_sync(&dev->check_pres_timer);
997 cancel_work_sync(&dev->check_pres_work);
998 }
Samuel Ortizd6469602011-12-14 16:43:12 +0100999
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -03001000 rc = nfc_genl_device_removed(dev);
1001 if (rc)
Eric Lapuyadef0c91032012-11-26 18:06:27 +01001002 pr_debug("The userspace won't be notified that the device %s "
1003 "was removed\n", dev_name(&dev->dev));
1004
1005 nfc_llcp_unregister_device(dev);
1006
1007 mutex_lock(&nfc_devlist_mutex);
1008 nfc_devlist_generation++;
1009 device_del(&dev->dev);
1010 mutex_unlock(&nfc_devlist_mutex);
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -03001011
Samuel Ortiz7eda8b8e92012-10-22 15:57:58 +02001012 ida_simple_remove(&nfc_index_ida, id);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -03001013}
1014EXPORT_SYMBOL(nfc_unregister_device);
1015
1016static int __init nfc_init(void)
1017{
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -03001018 int rc;
1019
Joe Perchesed1e0ad2011-11-29 11:37:32 -08001020 pr_info("NFC Core ver %s\n", VERSION);
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -03001021
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -03001022 rc = class_register(&nfc_class);
1023 if (rc)
1024 return rc;
1025
1026 rc = nfc_genl_init();
1027 if (rc)
1028 goto err_genl;
1029
1030 /* the first generation must not be 0 */
1031 nfc_devlist_generation = 1;
1032
Lauro Ramos Venancio23b78692011-07-01 19:31:36 -03001033 rc = rawsock_init();
1034 if (rc)
1035 goto err_rawsock;
1036
Samuel Ortizd6469602011-12-14 16:43:12 +01001037 rc = nfc_llcp_init();
1038 if (rc)
1039 goto err_llcp_sock;
1040
Aloisio Almeida Jrc7fe3b52011-07-01 19:31:35 -03001041 rc = af_nfc_init();
1042 if (rc)
1043 goto err_af_nfc;
1044
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -03001045 return 0;
1046
Aloisio Almeida Jrc7fe3b52011-07-01 19:31:35 -03001047err_af_nfc:
Samuel Ortizd6469602011-12-14 16:43:12 +01001048 nfc_llcp_exit();
1049err_llcp_sock:
Lauro Ramos Venancio23b78692011-07-01 19:31:36 -03001050 rawsock_exit();
1051err_rawsock:
Aloisio Almeida Jrc7fe3b52011-07-01 19:31:35 -03001052 nfc_genl_exit();
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -03001053err_genl:
1054 class_unregister(&nfc_class);
1055 return rc;
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -03001056}
1057
1058static void __exit nfc_exit(void)
1059{
Aloisio Almeida Jrc7fe3b52011-07-01 19:31:35 -03001060 af_nfc_exit();
Samuel Ortizd6469602011-12-14 16:43:12 +01001061 nfc_llcp_exit();
Lauro Ramos Venancio23b78692011-07-01 19:31:36 -03001062 rawsock_exit();
Lauro Ramos Venancio4d12b8b2011-07-01 19:31:34 -03001063 nfc_genl_exit();
Lauro Ramos Venancio3e256b82011-07-01 19:31:33 -03001064 class_unregister(&nfc_class);
1065}
1066
1067subsys_initcall(nfc_init);
1068module_exit(nfc_exit);
1069
1070MODULE_AUTHOR("Lauro Ramos Venancio <lauro.venancio@openbossa.org>");
1071MODULE_DESCRIPTION("NFC Core ver " VERSION);
1072MODULE_VERSION(VERSION);
1073MODULE_LICENSE("GPL");
Samuel Ortiz1155bb62012-06-12 00:35:50 +02001074MODULE_ALIAS_NETPROTO(PF_NFC);
Samuel Ortiz5df16ca2012-06-12 16:54:16 +02001075MODULE_ALIAS_GENL_FAMILY(NFC_GENL_NAME);