Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
Jeff Kirsher | 98b32de | 2013-12-06 08:56:16 -0800 | [diff] [blame] | 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #define pr_fmt(fmt) "hci: %s: " fmt, __func__ |
| 19 | |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/nfc.h> |
| 24 | |
| 25 | #include <net/nfc/nfc.h> |
| 26 | #include <net/nfc/hci.h> |
Eric Lapuyade | 67cccfe | 2012-09-13 17:10:00 +0200 | [diff] [blame] | 27 | #include <net/nfc/llc.h> |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 28 | |
| 29 | #include "hci.h" |
| 30 | |
| 31 | /* Largest headroom needed for outgoing HCI commands */ |
| 32 | #define HCI_CMDS_HEADROOM 1 |
| 33 | |
Eric Lapuyade | 84d4819 | 2012-10-17 16:50:10 +0200 | [diff] [blame] | 34 | int nfc_hci_result_to_errno(u8 result) |
Eric Lapuyade | 6c1c5b9 | 2012-05-03 15:35:25 +0200 | [diff] [blame] | 35 | { |
| 36 | switch (result) { |
| 37 | case NFC_HCI_ANY_OK: |
| 38 | return 0; |
Eric Lapuyade | 23f7e6d | 2012-10-17 16:48:21 +0200 | [diff] [blame] | 39 | case NFC_HCI_ANY_E_REG_PAR_UNKNOWN: |
| 40 | return -EOPNOTSUPP; |
Eric Lapuyade | 6c1c5b9 | 2012-05-03 15:35:25 +0200 | [diff] [blame] | 41 | case NFC_HCI_ANY_E_TIMEOUT: |
| 42 | return -ETIME; |
| 43 | default: |
| 44 | return -1; |
| 45 | } |
| 46 | } |
Eric Lapuyade | 84d4819 | 2012-10-17 16:50:10 +0200 | [diff] [blame] | 47 | EXPORT_SYMBOL(nfc_hci_result_to_errno); |
Eric Lapuyade | 6c1c5b9 | 2012-05-03 15:35:25 +0200 | [diff] [blame] | 48 | |
Christophe Ricard | 118278f | 2015-01-27 01:18:12 +0100 | [diff] [blame] | 49 | void nfc_hci_reset_pipes(struct nfc_hci_dev *hdev) |
| 50 | { |
| 51 | int i = 0; |
| 52 | |
| 53 | for (i = 0; i < NFC_HCI_MAX_PIPES; i++) { |
| 54 | hdev->pipes[i].gate = NFC_HCI_INVALID_GATE; |
| 55 | hdev->pipes[i].dest_host = NFC_HCI_INVALID_HOST; |
| 56 | } |
| 57 | memset(hdev->gate2pipe, NFC_HCI_INVALID_PIPE, sizeof(hdev->gate2pipe)); |
| 58 | } |
| 59 | EXPORT_SYMBOL(nfc_hci_reset_pipes); |
| 60 | |
| 61 | void nfc_hci_reset_pipes_per_host(struct nfc_hci_dev *hdev, u8 host) |
| 62 | { |
| 63 | int i = 0; |
| 64 | |
| 65 | for (i = 0; i < NFC_HCI_MAX_PIPES; i++) { |
| 66 | if (hdev->pipes[i].dest_host != host) |
| 67 | continue; |
| 68 | |
| 69 | hdev->pipes[i].gate = NFC_HCI_INVALID_GATE; |
| 70 | hdev->pipes[i].dest_host = NFC_HCI_INVALID_HOST; |
| 71 | } |
| 72 | } |
| 73 | EXPORT_SYMBOL(nfc_hci_reset_pipes_per_host); |
| 74 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 75 | static void nfc_hci_msg_tx_work(struct work_struct *work) |
| 76 | { |
| 77 | struct nfc_hci_dev *hdev = container_of(work, struct nfc_hci_dev, |
| 78 | msg_tx_work); |
| 79 | struct hci_msg *msg; |
| 80 | struct sk_buff *skb; |
| 81 | int r = 0; |
| 82 | |
| 83 | mutex_lock(&hdev->msg_tx_mutex); |
Eric Lapuyade | f0c9103 | 2012-11-26 18:06:27 +0100 | [diff] [blame] | 84 | if (hdev->shutting_down) |
| 85 | goto exit; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 86 | |
| 87 | if (hdev->cmd_pending_msg) { |
| 88 | if (timer_pending(&hdev->cmd_timer) == 0) { |
| 89 | if (hdev->cmd_pending_msg->cb) |
Eric Lapuyade | b5faa64 | 2012-09-11 10:41:41 +0200 | [diff] [blame] | 90 | hdev->cmd_pending_msg->cb(hdev-> |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 91 | cmd_pending_msg-> |
Eric Lapuyade | b5faa64 | 2012-09-11 10:41:41 +0200 | [diff] [blame] | 92 | cb_context, |
| 93 | NULL, |
| 94 | -ETIME); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 95 | kfree(hdev->cmd_pending_msg); |
| 96 | hdev->cmd_pending_msg = NULL; |
Szymon Janc | 0f45077 | 2012-10-17 15:23:39 +0200 | [diff] [blame] | 97 | } else { |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 98 | goto exit; |
Szymon Janc | 0f45077 | 2012-10-17 15:23:39 +0200 | [diff] [blame] | 99 | } |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | next_msg: |
| 103 | if (list_empty(&hdev->msg_tx_queue)) |
| 104 | goto exit; |
| 105 | |
| 106 | msg = list_first_entry(&hdev->msg_tx_queue, struct hci_msg, msg_l); |
| 107 | list_del(&msg->msg_l); |
| 108 | |
| 109 | pr_debug("msg_tx_queue has a cmd to send\n"); |
| 110 | while ((skb = skb_dequeue(&msg->msg_frags)) != NULL) { |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 111 | r = nfc_llc_xmit_from_hci(hdev->llc, skb); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 112 | if (r < 0) { |
| 113 | kfree_skb(skb); |
| 114 | skb_queue_purge(&msg->msg_frags); |
| 115 | if (msg->cb) |
Eric Lapuyade | b5faa64 | 2012-09-11 10:41:41 +0200 | [diff] [blame] | 116 | msg->cb(msg->cb_context, NULL, r); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 117 | kfree(msg); |
| 118 | break; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | if (r) |
| 123 | goto next_msg; |
| 124 | |
| 125 | if (msg->wait_response == false) { |
| 126 | kfree(msg); |
| 127 | goto next_msg; |
| 128 | } |
| 129 | |
| 130 | hdev->cmd_pending_msg = msg; |
| 131 | mod_timer(&hdev->cmd_timer, jiffies + |
| 132 | msecs_to_jiffies(hdev->cmd_pending_msg->completion_delay)); |
| 133 | |
| 134 | exit: |
| 135 | mutex_unlock(&hdev->msg_tx_mutex); |
| 136 | } |
| 137 | |
| 138 | static void nfc_hci_msg_rx_work(struct work_struct *work) |
| 139 | { |
| 140 | struct nfc_hci_dev *hdev = container_of(work, struct nfc_hci_dev, |
| 141 | msg_rx_work); |
| 142 | struct sk_buff *skb; |
| 143 | struct hcp_message *message; |
| 144 | u8 pipe; |
| 145 | u8 type; |
| 146 | u8 instruction; |
| 147 | |
| 148 | while ((skb = skb_dequeue(&hdev->msg_rx_queue)) != NULL) { |
| 149 | pipe = skb->data[0]; |
| 150 | skb_pull(skb, NFC_HCI_HCP_PACKET_HEADER_LEN); |
| 151 | message = (struct hcp_message *)skb->data; |
| 152 | type = HCP_MSG_GET_TYPE(message->header); |
| 153 | instruction = HCP_MSG_GET_CMD(message->header); |
| 154 | skb_pull(skb, NFC_HCI_HCP_MESSAGE_HEADER_LEN); |
| 155 | |
| 156 | nfc_hci_hcp_message_rx(hdev, pipe, type, instruction, skb); |
| 157 | } |
| 158 | } |
| 159 | |
Eric Lapuyade | ccca0d6 | 2012-05-03 15:59:37 +0200 | [diff] [blame] | 160 | static void __nfc_hci_cmd_completion(struct nfc_hci_dev *hdev, int err, |
| 161 | struct sk_buff *skb) |
| 162 | { |
| 163 | del_timer_sync(&hdev->cmd_timer); |
| 164 | |
| 165 | if (hdev->cmd_pending_msg->cb) |
Eric Lapuyade | b5faa64 | 2012-09-11 10:41:41 +0200 | [diff] [blame] | 166 | hdev->cmd_pending_msg->cb(hdev->cmd_pending_msg->cb_context, |
| 167 | skb, err); |
Eric Lapuyade | ccca0d6 | 2012-05-03 15:59:37 +0200 | [diff] [blame] | 168 | else |
| 169 | kfree_skb(skb); |
| 170 | |
| 171 | kfree(hdev->cmd_pending_msg); |
| 172 | hdev->cmd_pending_msg = NULL; |
| 173 | |
Linus Torvalds | 916082b | 2012-10-02 16:01:31 -0700 | [diff] [blame] | 174 | schedule_work(&hdev->msg_tx_work); |
Eric Lapuyade | ccca0d6 | 2012-05-03 15:59:37 +0200 | [diff] [blame] | 175 | } |
| 176 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 177 | void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result, |
| 178 | struct sk_buff *skb) |
| 179 | { |
| 180 | mutex_lock(&hdev->msg_tx_mutex); |
| 181 | |
| 182 | if (hdev->cmd_pending_msg == NULL) { |
| 183 | kfree_skb(skb); |
| 184 | goto exit; |
| 185 | } |
| 186 | |
Eric Lapuyade | ccca0d6 | 2012-05-03 15:59:37 +0200 | [diff] [blame] | 187 | __nfc_hci_cmd_completion(hdev, nfc_hci_result_to_errno(result), skb); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 188 | |
| 189 | exit: |
| 190 | mutex_unlock(&hdev->msg_tx_mutex); |
| 191 | } |
| 192 | |
| 193 | void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, |
| 194 | struct sk_buff *skb) |
| 195 | { |
Christophe Ricard | deff5aa | 2014-11-13 00:30:42 +0100 | [diff] [blame] | 196 | int r = 0; |
Christophe Ricard | 118278f | 2015-01-27 01:18:12 +0100 | [diff] [blame] | 197 | u8 gate = hdev->pipes[pipe].gate; |
Christophe Ricard | deff5aa | 2014-11-13 00:30:42 +0100 | [diff] [blame] | 198 | u8 local_gate, new_pipe; |
| 199 | u8 gate_opened = 0x00; |
| 200 | |
| 201 | pr_debug("from gate %x pipe %x cmd %x\n", gate, pipe, cmd); |
| 202 | |
| 203 | switch (cmd) { |
| 204 | case NFC_HCI_ADM_NOTIFY_PIPE_CREATED: |
| 205 | if (skb->len != 5) { |
| 206 | r = -EPROTO; |
| 207 | break; |
| 208 | } |
| 209 | |
| 210 | local_gate = skb->data[3]; |
| 211 | new_pipe = skb->data[4]; |
Christophe Ricard | af77522 | 2015-01-27 01:18:13 +0100 | [diff] [blame^] | 212 | nfc_hci_hcp_message_tx(hdev, pipe, NFC_HCI_HCP_RESPONSE, |
| 213 | NFC_HCI_ANY_OK, NULL, 0, NULL, NULL, 0); |
Christophe Ricard | deff5aa | 2014-11-13 00:30:42 +0100 | [diff] [blame] | 214 | |
| 215 | /* save the new created pipe and bind with local gate, |
| 216 | * the description for skb->data[3] is destination gate id |
| 217 | * but since we received this cmd from host controller, we |
| 218 | * are the destination and it is our local gate |
| 219 | */ |
| 220 | hdev->gate2pipe[local_gate] = new_pipe; |
| 221 | break; |
| 222 | case NFC_HCI_ANY_OPEN_PIPE: |
| 223 | /* if the pipe is already created, we allow remote host to |
| 224 | * open it |
| 225 | */ |
| 226 | if (gate != 0xff) |
Christophe Ricard | af77522 | 2015-01-27 01:18:13 +0100 | [diff] [blame^] | 227 | nfc_hci_hcp_message_tx(hdev, pipe, NFC_HCI_HCP_RESPONSE, |
| 228 | NFC_HCI_ANY_OK, &gate_opened, 1, |
| 229 | NULL, NULL, 0); |
Christophe Ricard | deff5aa | 2014-11-13 00:30:42 +0100 | [diff] [blame] | 230 | break; |
Christophe Ricard | a2ae218 | 2014-11-13 00:30:43 +0100 | [diff] [blame] | 231 | case NFC_HCI_ADM_NOTIFY_ALL_PIPE_CLEARED: |
Christophe Ricard | af77522 | 2015-01-27 01:18:13 +0100 | [diff] [blame^] | 232 | nfc_hci_hcp_message_tx(hdev, pipe, NFC_HCI_HCP_RESPONSE, |
| 233 | NFC_HCI_ANY_OK, NULL, 0, NULL, NULL, 0); |
| 234 | |
Christophe Ricard | a2ae218 | 2014-11-13 00:30:43 +0100 | [diff] [blame] | 235 | break; |
Christophe Ricard | deff5aa | 2014-11-13 00:30:42 +0100 | [diff] [blame] | 236 | default: |
| 237 | pr_info("Discarded unknown cmd %x to gate %x\n", cmd, gate); |
| 238 | r = -EINVAL; |
| 239 | break; |
| 240 | } |
| 241 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 242 | kfree_skb(skb); |
| 243 | } |
| 244 | |
Eric Lapuyade | 9c5121a | 2012-10-23 11:37:43 +0200 | [diff] [blame] | 245 | u32 nfc_hci_sak_to_protocol(u8 sak) |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 246 | { |
| 247 | switch (NFC_HCI_TYPE_A_SEL_PROT(sak)) { |
| 248 | case NFC_HCI_TYPE_A_SEL_PROT_MIFARE: |
| 249 | return NFC_PROTO_MIFARE_MASK; |
| 250 | case NFC_HCI_TYPE_A_SEL_PROT_ISO14443: |
| 251 | return NFC_PROTO_ISO14443_MASK; |
| 252 | case NFC_HCI_TYPE_A_SEL_PROT_DEP: |
| 253 | return NFC_PROTO_NFC_DEP_MASK; |
| 254 | case NFC_HCI_TYPE_A_SEL_PROT_ISO14443_DEP: |
| 255 | return NFC_PROTO_ISO14443_MASK | NFC_PROTO_NFC_DEP_MASK; |
| 256 | default: |
| 257 | return 0xffffffff; |
| 258 | } |
| 259 | } |
Eric Lapuyade | 9c5121a | 2012-10-23 11:37:43 +0200 | [diff] [blame] | 260 | EXPORT_SYMBOL(nfc_hci_sak_to_protocol); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 261 | |
Arron Wang | f7a5f6c | 2012-09-27 17:32:55 +0800 | [diff] [blame] | 262 | int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate) |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 263 | { |
| 264 | struct nfc_target *targets; |
| 265 | struct sk_buff *atqa_skb = NULL; |
| 266 | struct sk_buff *sak_skb = NULL; |
Eric Lapuyade | 81b3039 | 2012-07-12 20:27:54 +0200 | [diff] [blame] | 267 | struct sk_buff *uid_skb = NULL; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 268 | int r; |
| 269 | |
| 270 | pr_debug("from gate %d\n", gate); |
| 271 | |
| 272 | targets = kzalloc(sizeof(struct nfc_target), GFP_KERNEL); |
| 273 | if (targets == NULL) |
| 274 | return -ENOMEM; |
| 275 | |
| 276 | switch (gate) { |
| 277 | case NFC_HCI_RF_READER_A_GATE: |
| 278 | r = nfc_hci_get_param(hdev, NFC_HCI_RF_READER_A_GATE, |
| 279 | NFC_HCI_RF_READER_A_ATQA, &atqa_skb); |
| 280 | if (r < 0) |
| 281 | goto exit; |
| 282 | |
| 283 | r = nfc_hci_get_param(hdev, NFC_HCI_RF_READER_A_GATE, |
| 284 | NFC_HCI_RF_READER_A_SAK, &sak_skb); |
| 285 | if (r < 0) |
| 286 | goto exit; |
| 287 | |
| 288 | if (atqa_skb->len != 2 || sak_skb->len != 1) { |
| 289 | r = -EPROTO; |
| 290 | goto exit; |
| 291 | } |
| 292 | |
| 293 | targets->supported_protocols = |
| 294 | nfc_hci_sak_to_protocol(sak_skb->data[0]); |
| 295 | if (targets->supported_protocols == 0xffffffff) { |
| 296 | r = -EPROTO; |
| 297 | goto exit; |
| 298 | } |
| 299 | |
Christophe Ricard | 74157ef | 2014-04-01 00:34:01 +0200 | [diff] [blame] | 300 | targets->sens_res = be16_to_cpu(*(__be16 *)atqa_skb->data); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 301 | targets->sel_res = sak_skb->data[0]; |
| 302 | |
Eric Lapuyade | 81b3039 | 2012-07-12 20:27:54 +0200 | [diff] [blame] | 303 | r = nfc_hci_get_param(hdev, NFC_HCI_RF_READER_A_GATE, |
| 304 | NFC_HCI_RF_READER_A_UID, &uid_skb); |
| 305 | if (r < 0) |
| 306 | goto exit; |
| 307 | |
| 308 | if (uid_skb->len == 0 || uid_skb->len > NFC_NFCID1_MAXSIZE) { |
| 309 | r = -EPROTO; |
| 310 | goto exit; |
| 311 | } |
| 312 | |
| 313 | memcpy(targets->nfcid1, uid_skb->data, uid_skb->len); |
| 314 | targets->nfcid1_len = uid_skb->len; |
| 315 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 316 | if (hdev->ops->complete_target_discovered) { |
| 317 | r = hdev->ops->complete_target_discovered(hdev, gate, |
| 318 | targets); |
| 319 | if (r < 0) |
| 320 | goto exit; |
| 321 | } |
| 322 | break; |
| 323 | case NFC_HCI_RF_READER_B_GATE: |
Samuel Ortiz | 01d719a | 2012-07-04 00:14:04 +0200 | [diff] [blame] | 324 | targets->supported_protocols = NFC_PROTO_ISO14443_B_MASK; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 325 | break; |
| 326 | default: |
| 327 | if (hdev->ops->target_from_gate) |
| 328 | r = hdev->ops->target_from_gate(hdev, gate, targets); |
| 329 | else |
| 330 | r = -EPROTO; |
| 331 | if (r < 0) |
| 332 | goto exit; |
| 333 | |
| 334 | if (hdev->ops->complete_target_discovered) { |
| 335 | r = hdev->ops->complete_target_discovered(hdev, gate, |
| 336 | targets); |
| 337 | if (r < 0) |
| 338 | goto exit; |
| 339 | } |
| 340 | break; |
| 341 | } |
| 342 | |
Arron Wang | 928326f | 2012-09-27 17:32:56 +0800 | [diff] [blame] | 343 | /* if driver set the new gate, we will skip the old one */ |
| 344 | if (targets->hci_reader_gate == 0x00) |
| 345 | targets->hci_reader_gate = gate; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 346 | |
| 347 | r = nfc_targets_found(hdev->ndev, targets, 1); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 348 | |
| 349 | exit: |
| 350 | kfree(targets); |
| 351 | kfree_skb(atqa_skb); |
| 352 | kfree_skb(sak_skb); |
Eric Lapuyade | 81b3039 | 2012-07-12 20:27:54 +0200 | [diff] [blame] | 353 | kfree_skb(uid_skb); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 354 | |
| 355 | return r; |
| 356 | } |
Arron Wang | f7a5f6c | 2012-09-27 17:32:55 +0800 | [diff] [blame] | 357 | EXPORT_SYMBOL(nfc_hci_target_discovered); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 358 | |
| 359 | void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, |
| 360 | struct sk_buff *skb) |
| 361 | { |
| 362 | int r = 0; |
Christophe Ricard | 118278f | 2015-01-27 01:18:12 +0100 | [diff] [blame] | 363 | u8 gate = hdev->pipes[pipe].gate; |
Eric Lapuyade | 74a5b96 | 2012-10-17 16:49:12 +0200 | [diff] [blame] | 364 | |
Christophe Ricard | 118278f | 2015-01-27 01:18:12 +0100 | [diff] [blame] | 365 | if (gate == NFC_HCI_INVALID_GATE) { |
Eric Lapuyade | 74a5b96 | 2012-10-17 16:49:12 +0200 | [diff] [blame] | 366 | pr_err("Discarded event %x to unopened pipe %x\n", event, pipe); |
| 367 | goto exit; |
| 368 | } |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 369 | |
Eric Lapuyade | 40d06d3 | 2012-12-04 16:43:24 +0100 | [diff] [blame] | 370 | if (hdev->ops->event_received) { |
Christophe Ricard | fda7a49 | 2015-01-27 01:18:11 +0100 | [diff] [blame] | 371 | r = hdev->ops->event_received(hdev, pipe, event, skb); |
Eric Lapuyade | 40d06d3 | 2012-12-04 16:43:24 +0100 | [diff] [blame] | 372 | if (r <= 0) |
| 373 | goto exit_noskb; |
| 374 | } |
| 375 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 376 | switch (event) { |
| 377 | case NFC_HCI_EVT_TARGET_DISCOVERED: |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 378 | if (skb->len < 1) { /* no status data? */ |
| 379 | r = -EPROTO; |
| 380 | goto exit; |
| 381 | } |
| 382 | |
| 383 | if (skb->data[0] == 3) { |
| 384 | /* TODO: Multiple targets in field, none activated |
| 385 | * poll is supposedly stopped, but there is no |
| 386 | * single target to activate, so nothing to report |
| 387 | * up. |
| 388 | * if we need to restart poll, we must save the |
| 389 | * protocols from the initial poll and reuse here. |
| 390 | */ |
| 391 | } |
| 392 | |
| 393 | if (skb->data[0] != 0) { |
| 394 | r = -EPROTO; |
| 395 | goto exit; |
| 396 | } |
| 397 | |
Eric Lapuyade | 74a5b96 | 2012-10-17 16:49:12 +0200 | [diff] [blame] | 398 | r = nfc_hci_target_discovered(hdev, gate); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 399 | break; |
| 400 | default: |
Eric Lapuyade | 40d06d3 | 2012-12-04 16:43:24 +0100 | [diff] [blame] | 401 | pr_info("Discarded unknown event %x to gate %x\n", event, gate); |
| 402 | r = -EINVAL; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 403 | break; |
| 404 | } |
| 405 | |
| 406 | exit: |
| 407 | kfree_skb(skb); |
| 408 | |
Eric Lapuyade | 27c3119 | 2012-11-28 15:48:44 +0100 | [diff] [blame] | 409 | exit_noskb: |
Samuel Ortiz | 249eb5b | 2013-11-13 01:00:07 +0100 | [diff] [blame] | 410 | if (r) |
| 411 | nfc_hci_driver_failure(hdev, r); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | static void nfc_hci_cmd_timeout(unsigned long data) |
| 415 | { |
| 416 | struct nfc_hci_dev *hdev = (struct nfc_hci_dev *)data; |
| 417 | |
Linus Torvalds | 916082b | 2012-10-02 16:01:31 -0700 | [diff] [blame] | 418 | schedule_work(&hdev->msg_tx_work); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | static int hci_dev_connect_gates(struct nfc_hci_dev *hdev, u8 gate_count, |
Eric Lapuyade | a10d595 | 2012-06-05 14:42:11 +0200 | [diff] [blame] | 422 | struct nfc_hci_gate *gates) |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 423 | { |
| 424 | int r; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 425 | while (gate_count--) { |
Eric Lapuyade | a10d595 | 2012-06-05 14:42:11 +0200 | [diff] [blame] | 426 | r = nfc_hci_connect_gate(hdev, NFC_HCI_HOST_CONTROLLER_ID, |
| 427 | gates->gate, gates->pipe); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 428 | if (r < 0) |
| 429 | return r; |
Eric Lapuyade | a10d595 | 2012-06-05 14:42:11 +0200 | [diff] [blame] | 430 | gates++; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | static int hci_dev_session_init(struct nfc_hci_dev *hdev) |
| 437 | { |
| 438 | struct sk_buff *skb = NULL; |
| 439 | int r; |
Eric Lapuyade | a10d595 | 2012-06-05 14:42:11 +0200 | [diff] [blame] | 440 | |
| 441 | if (hdev->init_data.gates[0].gate != NFC_HCI_ADMIN_GATE) |
| 442 | return -EPROTO; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 443 | |
| 444 | r = nfc_hci_connect_gate(hdev, NFC_HCI_HOST_CONTROLLER_ID, |
Eric Lapuyade | a10d595 | 2012-06-05 14:42:11 +0200 | [diff] [blame] | 445 | hdev->init_data.gates[0].gate, |
| 446 | hdev->init_data.gates[0].pipe); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 447 | if (r < 0) |
| 448 | goto exit; |
| 449 | |
| 450 | r = nfc_hci_get_param(hdev, NFC_HCI_ADMIN_GATE, |
| 451 | NFC_HCI_ADMIN_SESSION_IDENTITY, &skb); |
| 452 | if (r < 0) |
| 453 | goto disconnect_all; |
| 454 | |
Christophe Ricard | e240bc3 | 2014-03-25 06:51:49 +0100 | [diff] [blame] | 455 | if (skb->len && skb->len == strlen(hdev->init_data.session_id) && |
| 456 | (memcmp(hdev->init_data.session_id, skb->data, |
| 457 | skb->len) == 0) && hdev->ops->load_session) { |
| 458 | /* Restore gate<->pipe table from some proprietary location. */ |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 459 | |
Christophe Ricard | e240bc3 | 2014-03-25 06:51:49 +0100 | [diff] [blame] | 460 | r = hdev->ops->load_session(hdev); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 461 | |
Christophe Ricard | e240bc3 | 2014-03-25 06:51:49 +0100 | [diff] [blame] | 462 | if (r < 0) |
| 463 | goto disconnect_all; |
| 464 | } else { |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 465 | |
Christophe Ricard | e240bc3 | 2014-03-25 06:51:49 +0100 | [diff] [blame] | 466 | r = nfc_hci_disconnect_all_gates(hdev); |
| 467 | if (r < 0) |
| 468 | goto exit; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 469 | |
Christophe Ricard | e240bc3 | 2014-03-25 06:51:49 +0100 | [diff] [blame] | 470 | r = hci_dev_connect_gates(hdev, hdev->init_data.gate_count, |
| 471 | hdev->init_data.gates); |
| 472 | if (r < 0) |
| 473 | goto disconnect_all; |
| 474 | |
| 475 | r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE, |
| 476 | NFC_HCI_ADMIN_SESSION_IDENTITY, |
| 477 | hdev->init_data.session_id, |
| 478 | strlen(hdev->init_data.session_id)); |
| 479 | } |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 480 | if (r == 0) |
| 481 | goto exit; |
| 482 | |
| 483 | disconnect_all: |
| 484 | nfc_hci_disconnect_all_gates(hdev); |
| 485 | |
| 486 | exit: |
Wei Yongjun | 33e5971 | 2012-08-28 21:02:40 +0800 | [diff] [blame] | 487 | kfree_skb(skb); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 488 | |
| 489 | return r; |
| 490 | } |
| 491 | |
| 492 | static int hci_dev_version(struct nfc_hci_dev *hdev) |
| 493 | { |
| 494 | int r; |
| 495 | struct sk_buff *skb; |
| 496 | |
| 497 | r = nfc_hci_get_param(hdev, NFC_HCI_ID_MGMT_GATE, |
| 498 | NFC_HCI_ID_MGMT_VERSION_SW, &skb); |
Eric Lapuyade | 23f7e6d | 2012-10-17 16:48:21 +0200 | [diff] [blame] | 499 | if (r == -EOPNOTSUPP) { |
| 500 | pr_info("Software/Hardware info not available\n"); |
| 501 | return 0; |
| 502 | } |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 503 | if (r < 0) |
| 504 | return r; |
| 505 | |
| 506 | if (skb->len != 3) { |
| 507 | kfree_skb(skb); |
| 508 | return -EINVAL; |
| 509 | } |
| 510 | |
| 511 | hdev->sw_romlib = (skb->data[0] & 0xf0) >> 4; |
| 512 | hdev->sw_patch = skb->data[0] & 0x0f; |
| 513 | hdev->sw_flashlib_major = skb->data[1]; |
| 514 | hdev->sw_flashlib_minor = skb->data[2]; |
| 515 | |
| 516 | kfree_skb(skb); |
| 517 | |
| 518 | r = nfc_hci_get_param(hdev, NFC_HCI_ID_MGMT_GATE, |
| 519 | NFC_HCI_ID_MGMT_VERSION_HW, &skb); |
| 520 | if (r < 0) |
| 521 | return r; |
| 522 | |
| 523 | if (skb->len != 3) { |
| 524 | kfree_skb(skb); |
| 525 | return -EINVAL; |
| 526 | } |
| 527 | |
| 528 | hdev->hw_derivative = (skb->data[0] & 0xe0) >> 5; |
| 529 | hdev->hw_version = skb->data[0] & 0x1f; |
| 530 | hdev->hw_mpw = (skb->data[1] & 0xc0) >> 6; |
| 531 | hdev->hw_software = skb->data[1] & 0x3f; |
| 532 | hdev->hw_bsid = skb->data[2]; |
| 533 | |
| 534 | kfree_skb(skb); |
| 535 | |
| 536 | pr_info("SOFTWARE INFO:\n"); |
| 537 | pr_info("RomLib : %d\n", hdev->sw_romlib); |
| 538 | pr_info("Patch : %d\n", hdev->sw_patch); |
| 539 | pr_info("FlashLib Major : %d\n", hdev->sw_flashlib_major); |
| 540 | pr_info("FlashLib Minor : %d\n", hdev->sw_flashlib_minor); |
| 541 | pr_info("HARDWARE INFO:\n"); |
| 542 | pr_info("Derivative : %d\n", hdev->hw_derivative); |
| 543 | pr_info("HW Version : %d\n", hdev->hw_version); |
| 544 | pr_info("#MPW : %d\n", hdev->hw_mpw); |
| 545 | pr_info("Software : %d\n", hdev->hw_software); |
| 546 | pr_info("BSID Version : %d\n", hdev->hw_bsid); |
| 547 | |
| 548 | return 0; |
| 549 | } |
| 550 | |
| 551 | static int hci_dev_up(struct nfc_dev *nfc_dev) |
| 552 | { |
| 553 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 554 | int r = 0; |
| 555 | |
| 556 | if (hdev->ops->open) { |
| 557 | r = hdev->ops->open(hdev); |
| 558 | if (r < 0) |
| 559 | return r; |
| 560 | } |
| 561 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 562 | r = nfc_llc_start(hdev->llc); |
| 563 | if (r < 0) |
| 564 | goto exit_close; |
| 565 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 566 | r = hci_dev_session_init(hdev); |
| 567 | if (r < 0) |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 568 | goto exit_llc; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 569 | |
| 570 | r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, |
| 571 | NFC_HCI_EVT_END_OPERATION, NULL, 0); |
| 572 | if (r < 0) |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 573 | goto exit_llc; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 574 | |
| 575 | if (hdev->ops->hci_ready) { |
| 576 | r = hdev->ops->hci_ready(hdev); |
| 577 | if (r < 0) |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 578 | goto exit_llc; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | r = hci_dev_version(hdev); |
| 582 | if (r < 0) |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 583 | goto exit_llc; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 584 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 585 | return 0; |
| 586 | |
| 587 | exit_llc: |
| 588 | nfc_llc_stop(hdev->llc); |
| 589 | |
| 590 | exit_close: |
| 591 | if (hdev->ops->close) |
| 592 | hdev->ops->close(hdev); |
| 593 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 594 | return r; |
| 595 | } |
| 596 | |
| 597 | static int hci_dev_down(struct nfc_dev *nfc_dev) |
| 598 | { |
| 599 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 600 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 601 | nfc_llc_stop(hdev->llc); |
| 602 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 603 | if (hdev->ops->close) |
| 604 | hdev->ops->close(hdev); |
| 605 | |
Christophe Ricard | 118278f | 2015-01-27 01:18:12 +0100 | [diff] [blame] | 606 | nfc_hci_reset_pipes(hdev); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 607 | |
| 608 | return 0; |
| 609 | } |
| 610 | |
Samuel Ortiz | fe7c580 | 2012-05-15 15:57:06 +0200 | [diff] [blame] | 611 | static int hci_start_poll(struct nfc_dev *nfc_dev, |
| 612 | u32 im_protocols, u32 tm_protocols) |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 613 | { |
| 614 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 615 | |
| 616 | if (hdev->ops->start_poll) |
Samuel Ortiz | fe7c580 | 2012-05-15 15:57:06 +0200 | [diff] [blame] | 617 | return hdev->ops->start_poll(hdev, im_protocols, tm_protocols); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 618 | else |
Eric Lapuyade | 03bed29 | 2012-05-07 12:31:31 +0200 | [diff] [blame] | 619 | return nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, |
Szymon Janc | 0f45077 | 2012-10-17 15:23:39 +0200 | [diff] [blame] | 620 | NFC_HCI_EVT_READER_REQUESTED, |
| 621 | NULL, 0); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | static void hci_stop_poll(struct nfc_dev *nfc_dev) |
| 625 | { |
| 626 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 627 | |
Christophe Ricard | 95f7687 | 2014-05-20 22:21:57 +0200 | [diff] [blame] | 628 | if (hdev->ops->stop_poll) |
| 629 | hdev->ops->stop_poll(hdev); |
| 630 | else |
| 631 | nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, |
| 632 | NFC_HCI_EVT_END_OPERATION, NULL, 0); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 633 | } |
| 634 | |
Arron Wang | c40d174 | 2012-09-27 17:32:57 +0800 | [diff] [blame] | 635 | static int hci_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, |
| 636 | __u8 comm_mode, __u8 *gb, size_t gb_len) |
| 637 | { |
| 638 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 639 | |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 640 | if (!hdev->ops->dep_link_up) |
| 641 | return 0; |
Arron Wang | c40d174 | 2012-09-27 17:32:57 +0800 | [diff] [blame] | 642 | |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 643 | return hdev->ops->dep_link_up(hdev, target, comm_mode, |
| 644 | gb, gb_len); |
Arron Wang | c40d174 | 2012-09-27 17:32:57 +0800 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | static int hci_dep_link_down(struct nfc_dev *nfc_dev) |
| 648 | { |
| 649 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 650 | |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 651 | if (!hdev->ops->dep_link_down) |
| 652 | return 0; |
Arron Wang | c40d174 | 2012-09-27 17:32:57 +0800 | [diff] [blame] | 653 | |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 654 | return hdev->ops->dep_link_down(hdev); |
Arron Wang | c40d174 | 2012-09-27 17:32:57 +0800 | [diff] [blame] | 655 | } |
| 656 | |
Eric Lapuyade | 9009943 | 2012-05-07 12:31:13 +0200 | [diff] [blame] | 657 | static int hci_activate_target(struct nfc_dev *nfc_dev, |
| 658 | struct nfc_target *target, u32 protocol) |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 659 | { |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 660 | return 0; |
| 661 | } |
| 662 | |
Eric Lapuyade | 9009943 | 2012-05-07 12:31:13 +0200 | [diff] [blame] | 663 | static void hci_deactivate_target(struct nfc_dev *nfc_dev, |
| 664 | struct nfc_target *target) |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 665 | { |
| 666 | } |
| 667 | |
Eric Lapuyade | f3e8fb5 | 2012-09-11 10:43:50 +0200 | [diff] [blame] | 668 | #define HCI_CB_TYPE_TRANSCEIVE 1 |
| 669 | |
| 670 | static void hci_transceive_cb(void *context, struct sk_buff *skb, int err) |
| 671 | { |
| 672 | struct nfc_hci_dev *hdev = context; |
| 673 | |
| 674 | switch (hdev->async_cb_type) { |
| 675 | case HCI_CB_TYPE_TRANSCEIVE: |
| 676 | /* |
| 677 | * TODO: Check RF Error indicator to make sure data is valid. |
| 678 | * It seems that HCI cmd can complete without error, but data |
| 679 | * can be invalid if an RF error occured? Ignore for now. |
| 680 | */ |
| 681 | if (err == 0) |
| 682 | skb_trim(skb, skb->len - 1); /* RF Err ind */ |
| 683 | |
| 684 | hdev->async_cb(hdev->async_cb_context, skb, err); |
| 685 | break; |
| 686 | default: |
| 687 | if (err == 0) |
| 688 | kfree_skb(skb); |
| 689 | break; |
| 690 | } |
| 691 | } |
| 692 | |
Samuel Ortiz | be9ae4c | 2012-05-16 15:55:48 +0200 | [diff] [blame] | 693 | static int hci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target, |
| 694 | struct sk_buff *skb, data_exchange_cb_t cb, |
| 695 | void *cb_context) |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 696 | { |
| 697 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 698 | int r; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 699 | |
Eric Lapuyade | 9009943 | 2012-05-07 12:31:13 +0200 | [diff] [blame] | 700 | pr_debug("target_idx=%d\n", target->idx); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 701 | |
| 702 | switch (target->hci_reader_gate) { |
| 703 | case NFC_HCI_RF_READER_A_GATE: |
| 704 | case NFC_HCI_RF_READER_B_GATE: |
Arron Wang | e810762 | 2012-09-27 17:32:58 +0800 | [diff] [blame] | 705 | if (hdev->ops->im_transceive) { |
| 706 | r = hdev->ops->im_transceive(hdev, target, skb, cb, |
Eric Lapuyade | f3e8fb5 | 2012-09-11 10:43:50 +0200 | [diff] [blame] | 707 | cb_context); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 708 | if (r <= 0) /* handled */ |
| 709 | break; |
| 710 | } |
| 711 | |
| 712 | *skb_push(skb, 1) = 0; /* CTR, see spec:10.2.2.1 */ |
Eric Lapuyade | f3e8fb5 | 2012-09-11 10:43:50 +0200 | [diff] [blame] | 713 | |
| 714 | hdev->async_cb_type = HCI_CB_TYPE_TRANSCEIVE; |
| 715 | hdev->async_cb = cb; |
| 716 | hdev->async_cb_context = cb_context; |
| 717 | |
| 718 | r = nfc_hci_send_cmd_async(hdev, target->hci_reader_gate, |
| 719 | NFC_HCI_WR_XCHG_DATA, skb->data, |
| 720 | skb->len, hci_transceive_cb, hdev); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 721 | break; |
| 722 | default: |
Arron Wang | e810762 | 2012-09-27 17:32:58 +0800 | [diff] [blame] | 723 | if (hdev->ops->im_transceive) { |
| 724 | r = hdev->ops->im_transceive(hdev, target, skb, cb, |
Eric Lapuyade | f3e8fb5 | 2012-09-11 10:43:50 +0200 | [diff] [blame] | 725 | cb_context); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 726 | if (r == 1) |
| 727 | r = -ENOTSUPP; |
Szymon Janc | 0f45077 | 2012-10-17 15:23:39 +0200 | [diff] [blame] | 728 | } else { |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 729 | r = -ENOTSUPP; |
Szymon Janc | 0f45077 | 2012-10-17 15:23:39 +0200 | [diff] [blame] | 730 | } |
Eric Lapuyade | f3e8fb5 | 2012-09-11 10:43:50 +0200 | [diff] [blame] | 731 | break; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | kfree_skb(skb); |
| 735 | |
Eric Lapuyade | f3e8fb5 | 2012-09-11 10:43:50 +0200 | [diff] [blame] | 736 | return r; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 737 | } |
| 738 | |
Arron Wang | 984d334 | 2012-10-08 14:54:39 +0800 | [diff] [blame] | 739 | static int hci_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb) |
Arron Wang | e810762 | 2012-09-27 17:32:58 +0800 | [diff] [blame] | 740 | { |
| 741 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 742 | |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 743 | if (!hdev->ops->tm_send) { |
| 744 | kfree_skb(skb); |
| 745 | return -ENOTSUPP; |
| 746 | } |
Eric Lapuyade | 924d4a0 | 2012-12-04 16:44:25 +0100 | [diff] [blame] | 747 | |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 748 | return hdev->ops->tm_send(hdev, skb); |
Arron Wang | e810762 | 2012-09-27 17:32:58 +0800 | [diff] [blame] | 749 | } |
| 750 | |
Eric Lapuyade | 1676f75 | 2012-05-07 12:31:16 +0200 | [diff] [blame] | 751 | static int hci_check_presence(struct nfc_dev *nfc_dev, |
| 752 | struct nfc_target *target) |
| 753 | { |
| 754 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 755 | |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 756 | if (!hdev->ops->check_presence) |
| 757 | return 0; |
Eric Lapuyade | 1676f75 | 2012-05-07 12:31:16 +0200 | [diff] [blame] | 758 | |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 759 | return hdev->ops->check_presence(hdev, target); |
Eric Lapuyade | 1676f75 | 2012-05-07 12:31:16 +0200 | [diff] [blame] | 760 | } |
| 761 | |
Samuel Ortiz | 0a94630 | 2013-05-10 11:57:06 +0200 | [diff] [blame] | 762 | static int hci_discover_se(struct nfc_dev *nfc_dev) |
| 763 | { |
| 764 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 765 | |
| 766 | if (hdev->ops->discover_se) |
| 767 | return hdev->ops->discover_se(hdev); |
| 768 | |
| 769 | return 0; |
| 770 | } |
| 771 | |
| 772 | static int hci_enable_se(struct nfc_dev *nfc_dev, u32 se_idx) |
| 773 | { |
| 774 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 775 | |
| 776 | if (hdev->ops->enable_se) |
| 777 | return hdev->ops->enable_se(hdev, se_idx); |
| 778 | |
| 779 | return 0; |
| 780 | } |
| 781 | |
| 782 | static int hci_disable_se(struct nfc_dev *nfc_dev, u32 se_idx) |
| 783 | { |
| 784 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 785 | |
| 786 | if (hdev->ops->disable_se) |
Dan Carpenter | 4eba11e | 2013-06-18 01:48:26 +0300 | [diff] [blame] | 787 | return hdev->ops->disable_se(hdev, se_idx); |
Samuel Ortiz | 0a94630 | 2013-05-10 11:57:06 +0200 | [diff] [blame] | 788 | |
| 789 | return 0; |
| 790 | } |
| 791 | |
Christophe Ricard | 9b8d32b | 2014-11-13 00:30:34 +0100 | [diff] [blame] | 792 | static int hci_se_io(struct nfc_dev *nfc_dev, u32 se_idx, |
| 793 | u8 *apdu, size_t apdu_length, |
| 794 | se_io_cb_t cb, void *cb_context) |
| 795 | { |
| 796 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 797 | |
| 798 | if (hdev->ops->se_io) |
| 799 | return hdev->ops->se_io(hdev, se_idx, apdu, |
| 800 | apdu_length, cb, cb_context); |
| 801 | |
| 802 | return 0; |
| 803 | } |
| 804 | |
Eric Lapuyade | 72b06f7 | 2012-06-11 13:36:52 +0200 | [diff] [blame] | 805 | static void nfc_hci_failure(struct nfc_hci_dev *hdev, int err) |
Eric Lapuyade | a9a741a | 2012-04-30 18:21:51 +0200 | [diff] [blame] | 806 | { |
Eric Lapuyade | a070c85 | 2012-06-11 15:06:56 +0200 | [diff] [blame] | 807 | mutex_lock(&hdev->msg_tx_mutex); |
| 808 | |
| 809 | if (hdev->cmd_pending_msg == NULL) { |
| 810 | nfc_driver_failure(hdev->ndev, err); |
| 811 | goto exit; |
| 812 | } |
| 813 | |
| 814 | __nfc_hci_cmd_completion(hdev, err, NULL); |
| 815 | |
| 816 | exit: |
| 817 | mutex_unlock(&hdev->msg_tx_mutex); |
Eric Lapuyade | a9a741a | 2012-04-30 18:21:51 +0200 | [diff] [blame] | 818 | } |
Eric Lapuyade | 72b06f7 | 2012-06-11 13:36:52 +0200 | [diff] [blame] | 819 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 820 | static void nfc_hci_llc_failure(struct nfc_hci_dev *hdev, int err) |
Eric Lapuyade | 72b06f7 | 2012-06-11 13:36:52 +0200 | [diff] [blame] | 821 | { |
| 822 | nfc_hci_failure(hdev, err); |
| 823 | } |
Eric Lapuyade | a9a741a | 2012-04-30 18:21:51 +0200 | [diff] [blame] | 824 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 825 | static void nfc_hci_recv_from_llc(struct nfc_hci_dev *hdev, struct sk_buff *skb) |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 826 | { |
| 827 | struct hcp_packet *packet; |
| 828 | u8 type; |
| 829 | u8 instruction; |
| 830 | struct sk_buff *hcp_skb; |
| 831 | u8 pipe; |
| 832 | struct sk_buff *frag_skb; |
| 833 | int msg_len; |
| 834 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 835 | packet = (struct hcp_packet *)skb->data; |
| 836 | if ((packet->header & ~NFC_HCI_FRAGMENT) == 0) { |
| 837 | skb_queue_tail(&hdev->rx_hcp_frags, skb); |
| 838 | return; |
| 839 | } |
| 840 | |
| 841 | /* it's the last fragment. Does it need re-aggregation? */ |
| 842 | if (skb_queue_len(&hdev->rx_hcp_frags)) { |
| 843 | pipe = packet->header & NFC_HCI_FRAGMENT; |
| 844 | skb_queue_tail(&hdev->rx_hcp_frags, skb); |
| 845 | |
| 846 | msg_len = 0; |
| 847 | skb_queue_walk(&hdev->rx_hcp_frags, frag_skb) { |
| 848 | msg_len += (frag_skb->len - |
| 849 | NFC_HCI_HCP_PACKET_HEADER_LEN); |
| 850 | } |
| 851 | |
| 852 | hcp_skb = nfc_alloc_recv_skb(NFC_HCI_HCP_PACKET_HEADER_LEN + |
| 853 | msg_len, GFP_KERNEL); |
| 854 | if (hcp_skb == NULL) { |
Eric Lapuyade | 72b06f7 | 2012-06-11 13:36:52 +0200 | [diff] [blame] | 855 | nfc_hci_failure(hdev, -ENOMEM); |
| 856 | return; |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | *skb_put(hcp_skb, NFC_HCI_HCP_PACKET_HEADER_LEN) = pipe; |
| 860 | |
| 861 | skb_queue_walk(&hdev->rx_hcp_frags, frag_skb) { |
| 862 | msg_len = frag_skb->len - NFC_HCI_HCP_PACKET_HEADER_LEN; |
| 863 | memcpy(skb_put(hcp_skb, msg_len), |
| 864 | frag_skb->data + NFC_HCI_HCP_PACKET_HEADER_LEN, |
| 865 | msg_len); |
| 866 | } |
| 867 | |
| 868 | skb_queue_purge(&hdev->rx_hcp_frags); |
| 869 | } else { |
| 870 | packet->header &= NFC_HCI_FRAGMENT; |
| 871 | hcp_skb = skb; |
| 872 | } |
| 873 | |
| 874 | /* if this is a response, dispatch immediately to |
| 875 | * unblock waiting cmd context. Otherwise, enqueue to dispatch |
| 876 | * in separate context where handler can also execute command. |
| 877 | */ |
| 878 | packet = (struct hcp_packet *)hcp_skb->data; |
| 879 | type = HCP_MSG_GET_TYPE(packet->message.header); |
| 880 | if (type == NFC_HCI_HCP_RESPONSE) { |
| 881 | pipe = packet->header; |
| 882 | instruction = HCP_MSG_GET_CMD(packet->message.header); |
| 883 | skb_pull(hcp_skb, NFC_HCI_HCP_PACKET_HEADER_LEN + |
| 884 | NFC_HCI_HCP_MESSAGE_HEADER_LEN); |
| 885 | nfc_hci_hcp_message_rx(hdev, pipe, type, instruction, hcp_skb); |
| 886 | } else { |
| 887 | skb_queue_tail(&hdev->msg_rx_queue, hcp_skb); |
Linus Torvalds | 916082b | 2012-10-02 16:01:31 -0700 | [diff] [blame] | 888 | schedule_work(&hdev->msg_rx_work); |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 889 | } |
| 890 | } |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 891 | |
Samuel Ortiz | 9ea7187 | 2013-07-31 01:19:43 +0200 | [diff] [blame] | 892 | static int hci_fw_download(struct nfc_dev *nfc_dev, const char *firmware_name) |
Eric Lapuyade | 9a695d2 | 2013-04-29 17:47:42 +0200 | [diff] [blame] | 893 | { |
| 894 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); |
| 895 | |
Samuel Ortiz | 9ea7187 | 2013-07-31 01:19:43 +0200 | [diff] [blame] | 896 | if (!hdev->ops->fw_download) |
Samuel Ortiz | a395298 | 2013-05-25 01:21:21 +0200 | [diff] [blame] | 897 | return -ENOTSUPP; |
Eric Lapuyade | 9a695d2 | 2013-04-29 17:47:42 +0200 | [diff] [blame] | 898 | |
Samuel Ortiz | 9ea7187 | 2013-07-31 01:19:43 +0200 | [diff] [blame] | 899 | return hdev->ops->fw_download(hdev, firmware_name); |
Eric Lapuyade | 9a695d2 | 2013-04-29 17:47:42 +0200 | [diff] [blame] | 900 | } |
| 901 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 902 | static struct nfc_ops hci_nfc_ops = { |
| 903 | .dev_up = hci_dev_up, |
| 904 | .dev_down = hci_dev_down, |
| 905 | .start_poll = hci_start_poll, |
| 906 | .stop_poll = hci_stop_poll, |
Arron Wang | c40d174 | 2012-09-27 17:32:57 +0800 | [diff] [blame] | 907 | .dep_link_up = hci_dep_link_up, |
| 908 | .dep_link_down = hci_dep_link_down, |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 909 | .activate_target = hci_activate_target, |
| 910 | .deactivate_target = hci_deactivate_target, |
| 911 | .im_transceive = hci_transceive, |
Arron Wang | e810762 | 2012-09-27 17:32:58 +0800 | [diff] [blame] | 912 | .tm_send = hci_tm_send, |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 913 | .check_presence = hci_check_presence, |
Samuel Ortiz | 9ea7187 | 2013-07-31 01:19:43 +0200 | [diff] [blame] | 914 | .fw_download = hci_fw_download, |
Samuel Ortiz | 0a94630 | 2013-05-10 11:57:06 +0200 | [diff] [blame] | 915 | .discover_se = hci_discover_se, |
| 916 | .enable_se = hci_enable_se, |
| 917 | .disable_se = hci_disable_se, |
Christophe Ricard | 9b8d32b | 2014-11-13 00:30:34 +0100 | [diff] [blame] | 918 | .se_io = hci_se_io, |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 919 | }; |
| 920 | |
| 921 | struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, |
| 922 | struct nfc_hci_init_data *init_data, |
Eric Lapuyade | bf71ab8 | 2012-12-18 14:15:49 +0100 | [diff] [blame] | 923 | unsigned long quirks, |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 924 | u32 protocols, |
| 925 | const char *llc_name, |
| 926 | int tx_headroom, |
| 927 | int tx_tailroom, |
| 928 | int max_link_payload) |
| 929 | { |
| 930 | struct nfc_hci_dev *hdev; |
| 931 | |
| 932 | if (ops->xmit == NULL) |
| 933 | return NULL; |
| 934 | |
| 935 | if (protocols == 0) |
| 936 | return NULL; |
| 937 | |
| 938 | hdev = kzalloc(sizeof(struct nfc_hci_dev), GFP_KERNEL); |
| 939 | if (hdev == NULL) |
| 940 | return NULL; |
| 941 | |
| 942 | hdev->llc = nfc_llc_allocate(llc_name, hdev, ops->xmit, |
| 943 | nfc_hci_recv_from_llc, tx_headroom, |
| 944 | tx_tailroom, nfc_hci_llc_failure); |
| 945 | if (hdev->llc == NULL) { |
| 946 | kfree(hdev); |
| 947 | return NULL; |
| 948 | } |
| 949 | |
Samuel Ortiz | 0b456c4 | 2013-05-07 19:22:11 +0200 | [diff] [blame] | 950 | hdev->ndev = nfc_allocate_device(&hci_nfc_ops, protocols, |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 951 | tx_headroom + HCI_CMDS_HEADROOM, |
| 952 | tx_tailroom); |
| 953 | if (!hdev->ndev) { |
| 954 | nfc_llc_free(hdev->llc); |
| 955 | kfree(hdev); |
| 956 | return NULL; |
| 957 | } |
| 958 | |
| 959 | hdev->ops = ops; |
| 960 | hdev->max_data_link_payload = max_link_payload; |
| 961 | hdev->init_data = *init_data; |
| 962 | |
| 963 | nfc_set_drvdata(hdev->ndev, hdev); |
| 964 | |
Christophe Ricard | 118278f | 2015-01-27 01:18:12 +0100 | [diff] [blame] | 965 | nfc_hci_reset_pipes(hdev); |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 966 | |
Eric Lapuyade | bf71ab8 | 2012-12-18 14:15:49 +0100 | [diff] [blame] | 967 | hdev->quirks = quirks; |
| 968 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 969 | return hdev; |
| 970 | } |
| 971 | EXPORT_SYMBOL(nfc_hci_allocate_device); |
| 972 | |
| 973 | void nfc_hci_free_device(struct nfc_hci_dev *hdev) |
| 974 | { |
| 975 | nfc_free_device(hdev->ndev); |
| 976 | nfc_llc_free(hdev->llc); |
| 977 | kfree(hdev); |
| 978 | } |
| 979 | EXPORT_SYMBOL(nfc_hci_free_device); |
| 980 | |
| 981 | int nfc_hci_register_device(struct nfc_hci_dev *hdev) |
| 982 | { |
| 983 | mutex_init(&hdev->msg_tx_mutex); |
| 984 | |
| 985 | INIT_LIST_HEAD(&hdev->msg_tx_queue); |
| 986 | |
| 987 | INIT_WORK(&hdev->msg_tx_work, nfc_hci_msg_tx_work); |
| 988 | |
| 989 | init_timer(&hdev->cmd_timer); |
| 990 | hdev->cmd_timer.data = (unsigned long)hdev; |
| 991 | hdev->cmd_timer.function = nfc_hci_cmd_timeout; |
| 992 | |
| 993 | skb_queue_head_init(&hdev->rx_hcp_frags); |
| 994 | |
| 995 | INIT_WORK(&hdev->msg_rx_work, nfc_hci_msg_rx_work); |
| 996 | |
| 997 | skb_queue_head_init(&hdev->msg_rx_queue); |
| 998 | |
| 999 | return nfc_register_device(hdev->ndev); |
| 1000 | } |
| 1001 | EXPORT_SYMBOL(nfc_hci_register_device); |
| 1002 | |
| 1003 | void nfc_hci_unregister_device(struct nfc_hci_dev *hdev) |
| 1004 | { |
| 1005 | struct hci_msg *msg, *n; |
| 1006 | |
Eric Lapuyade | f0c9103 | 2012-11-26 18:06:27 +0100 | [diff] [blame] | 1007 | mutex_lock(&hdev->msg_tx_mutex); |
| 1008 | |
| 1009 | if (hdev->cmd_pending_msg) { |
| 1010 | if (hdev->cmd_pending_msg->cb) |
| 1011 | hdev->cmd_pending_msg->cb( |
| 1012 | hdev->cmd_pending_msg->cb_context, |
| 1013 | NULL, -ESHUTDOWN); |
| 1014 | kfree(hdev->cmd_pending_msg); |
| 1015 | hdev->cmd_pending_msg = NULL; |
| 1016 | } |
| 1017 | |
| 1018 | hdev->shutting_down = true; |
| 1019 | |
| 1020 | mutex_unlock(&hdev->msg_tx_mutex); |
| 1021 | |
| 1022 | del_timer_sync(&hdev->cmd_timer); |
| 1023 | cancel_work_sync(&hdev->msg_tx_work); |
| 1024 | |
| 1025 | cancel_work_sync(&hdev->msg_rx_work); |
| 1026 | |
| 1027 | nfc_unregister_device(hdev->ndev); |
| 1028 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 1029 | skb_queue_purge(&hdev->rx_hcp_frags); |
| 1030 | skb_queue_purge(&hdev->msg_rx_queue); |
| 1031 | |
| 1032 | list_for_each_entry_safe(msg, n, &hdev->msg_tx_queue, msg_l) { |
| 1033 | list_del(&msg->msg_l); |
| 1034 | skb_queue_purge(&msg->msg_frags); |
| 1035 | kfree(msg); |
| 1036 | } |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 1037 | } |
| 1038 | EXPORT_SYMBOL(nfc_hci_unregister_device); |
| 1039 | |
| 1040 | void nfc_hci_set_clientdata(struct nfc_hci_dev *hdev, void *clientdata) |
| 1041 | { |
| 1042 | hdev->clientdata = clientdata; |
| 1043 | } |
| 1044 | EXPORT_SYMBOL(nfc_hci_set_clientdata); |
| 1045 | |
| 1046 | void *nfc_hci_get_clientdata(struct nfc_hci_dev *hdev) |
| 1047 | { |
| 1048 | return hdev->clientdata; |
| 1049 | } |
| 1050 | EXPORT_SYMBOL(nfc_hci_get_clientdata); |
| 1051 | |
| 1052 | void nfc_hci_driver_failure(struct nfc_hci_dev *hdev, int err) |
| 1053 | { |
| 1054 | nfc_hci_failure(hdev, err); |
| 1055 | } |
| 1056 | EXPORT_SYMBOL(nfc_hci_driver_failure); |
| 1057 | |
Szymon Janc | 0f45077 | 2012-10-17 15:23:39 +0200 | [diff] [blame] | 1058 | void nfc_hci_recv_frame(struct nfc_hci_dev *hdev, struct sk_buff *skb) |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 1059 | { |
| 1060 | nfc_llc_rcv_from_drv(hdev->llc, skb); |
| 1061 | } |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 1062 | EXPORT_SYMBOL(nfc_hci_recv_frame); |
| 1063 | |
Eric Lapuyade | 67cccfe | 2012-09-13 17:10:00 +0200 | [diff] [blame] | 1064 | static int __init nfc_hci_init(void) |
| 1065 | { |
| 1066 | return nfc_llc_init(); |
| 1067 | } |
| 1068 | |
| 1069 | static void __exit nfc_hci_exit(void) |
| 1070 | { |
| 1071 | nfc_llc_exit(); |
| 1072 | } |
| 1073 | |
Eric Lapuyade | 412fda5 | 2012-09-18 19:45:48 +0200 | [diff] [blame] | 1074 | subsys_initcall(nfc_hci_init); |
Eric Lapuyade | 67cccfe | 2012-09-13 17:10:00 +0200 | [diff] [blame] | 1075 | module_exit(nfc_hci_exit); |
| 1076 | |
Eric Lapuyade | 8b8d2e0 | 2012-04-10 19:43:06 +0200 | [diff] [blame] | 1077 | MODULE_LICENSE("GPL"); |
Eric Lapuyade | 80faa59 | 2012-09-18 19:25:38 +0200 | [diff] [blame] | 1078 | MODULE_DESCRIPTION("NFC HCI Core"); |