Lines Matching full:ndev
43 struct nci_conn_info *nci_get_conn_info_by_conn_id(struct nci_dev *ndev, in nci_get_conn_info_by_conn_id() argument
48 list_for_each_entry(conn_info, &ndev->conn_info_list, list) { in nci_get_conn_info_by_conn_id()
56 int nci_get_conn_info_by_dest_type_params(struct nci_dev *ndev, u8 dest_type, in nci_get_conn_info_by_dest_type_params() argument
61 list_for_each_entry(conn_info, &ndev->conn_info_list, list) { in nci_get_conn_info_by_dest_type_params()
78 void nci_req_complete(struct nci_dev *ndev, int result) in nci_req_complete() argument
80 if (ndev->req_status == NCI_REQ_PEND) { in nci_req_complete()
81 ndev->req_result = result; in nci_req_complete()
82 ndev->req_status = NCI_REQ_DONE; in nci_req_complete()
83 complete(&ndev->req_completion); in nci_req_complete()
88 static void nci_req_cancel(struct nci_dev *ndev, int err) in nci_req_cancel() argument
90 if (ndev->req_status == NCI_REQ_PEND) { in nci_req_cancel()
91 ndev->req_result = err; in nci_req_cancel()
92 ndev->req_status = NCI_REQ_CANCELED; in nci_req_cancel()
93 complete(&ndev->req_completion); in nci_req_cancel()
98 static int __nci_request(struct nci_dev *ndev, in __nci_request() argument
99 void (*req)(struct nci_dev *ndev, const void *opt), in __nci_request() argument
105 ndev->req_status = NCI_REQ_PEND; in __nci_request()
107 reinit_completion(&ndev->req_completion); in __nci_request()
108 req(ndev, opt); in __nci_request()
110 wait_for_completion_interruptible_timeout(&ndev->req_completion, in __nci_request()
116 switch (ndev->req_status) { in __nci_request()
118 rc = nci_to_errno(ndev->req_result); in __nci_request()
122 rc = -ndev->req_result; in __nci_request()
136 ndev->req_status = ndev->req_result = 0; in __nci_request()
141 inline int nci_request(struct nci_dev *ndev, in nci_request() argument
142 void (*req)(struct nci_dev *ndev, in nci_request() argument
149 mutex_lock(&ndev->req_lock); in nci_request()
153 if (test_bit(NCI_UP, &ndev->flags)) in nci_request()
154 rc = __nci_request(ndev, req, opt, timeout); in nci_request()
157 mutex_unlock(&ndev->req_lock); in nci_request()
162 static void nci_reset_req(struct nci_dev *ndev, const void *opt) in nci_reset_req() argument
167 nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 1, &cmd); in nci_reset_req()
170 static void nci_init_req(struct nci_dev *ndev, const void *opt) in nci_init_req() argument
177 nci_send_cmd(ndev, NCI_OP_CORE_INIT_CMD, plen, opt); in nci_init_req()
180 static void nci_init_complete_req(struct nci_dev *ndev, const void *opt) in nci_init_complete_req() argument
191 for (i = 0; i < ndev->num_supported_rf_interfaces; i++) { in nci_init_complete_req()
192 if (ndev->supported_rf_interfaces[i] == in nci_init_complete_req()
199 } else if (ndev->supported_rf_interfaces[i] == in nci_init_complete_req()
212 nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_MAP_CMD, in nci_init_complete_req()
222 static void nci_set_config_req(struct nci_dev *ndev, const void *opt) in nci_set_config_req() argument
234 nci_send_cmd(ndev, NCI_OP_CORE_SET_CONFIG_CMD, (3 + param->len), &cmd); in nci_set_config_req()
242 static void nci_rf_discover_req(struct nci_dev *ndev, const void *opt) in nci_rf_discover_req() argument
297 nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_CMD, in nci_rf_discover_req()
307 static void nci_rf_discover_select_req(struct nci_dev *ndev, const void *opt) in nci_rf_discover_select_req() argument
329 nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_SELECT_CMD, in nci_rf_discover_select_req()
333 static void nci_rf_deactivate_req(struct nci_dev *ndev, const void *opt) in nci_rf_deactivate_req() argument
339 nci_send_cmd(ndev, NCI_OP_RF_DEACTIVATE_CMD, in nci_rf_deactivate_req()
349 static void nci_generic_req(struct nci_dev *ndev, const void *opt) in nci_generic_req() argument
353 nci_send_cmd(ndev, param->opcode, param->len, param->payload); in nci_generic_req()
356 int nci_prop_cmd(struct nci_dev *ndev, __u8 oid, size_t len, const __u8 *payload) in nci_prop_cmd() argument
364 return __nci_request(ndev, nci_generic_req, ¶m, in nci_prop_cmd()
369 int nci_core_cmd(struct nci_dev *ndev, __u16 opcode, size_t len, in nci_core_cmd() argument
378 return __nci_request(ndev, nci_generic_req, ¶m, in nci_core_cmd()
383 int nci_core_reset(struct nci_dev *ndev) in nci_core_reset() argument
385 return __nci_request(ndev, nci_reset_req, (void *)0, in nci_core_reset()
390 int nci_core_init(struct nci_dev *ndev) in nci_core_init() argument
392 return __nci_request(ndev, nci_init_req, (void *)0, in nci_core_init()
402 static void nci_send_data_req(struct nci_dev *ndev, const void *opt) in nci_send_data_req() argument
406 nci_send_data(ndev, data->conn_id, data->data); in nci_send_data_req()
411 struct nci_dev *ndev = (struct nci_dev *)context; in nci_nfcc_loopback_cb() local
414 conn_info = nci_get_conn_info_by_conn_id(ndev, ndev->cur_conn_id); in nci_nfcc_loopback_cb()
416 nci_req_complete(ndev, NCI_STATUS_REJECTED); in nci_nfcc_loopback_cb()
422 nci_req_complete(ndev, NCI_STATUS_OK); in nci_nfcc_loopback_cb()
425 int nci_nfcc_loopback(struct nci_dev *ndev, const void *data, size_t data_len, in nci_nfcc_loopback() argument
432 int conn_id = nci_get_conn_info_by_dest_type_params(ndev, in nci_nfcc_loopback()
436 r = nci_core_conn_create(ndev, NCI_DESTINATION_NFCC_LOOPBACK, in nci_nfcc_loopback()
441 conn_id = nci_get_conn_info_by_dest_type_params(ndev, in nci_nfcc_loopback()
446 conn_info = nci_get_conn_info_by_conn_id(ndev, conn_id); in nci_nfcc_loopback()
452 conn_info->data_exchange_cb_context = ndev; in nci_nfcc_loopback()
454 skb = nci_skb_alloc(ndev, NCI_DATA_HDR_SIZE + data_len, GFP_KERNEL); in nci_nfcc_loopback()
464 ndev->cur_conn_id = conn_id; in nci_nfcc_loopback()
465 r = nci_request(ndev, nci_send_data_req, &loopback_data, in nci_nfcc_loopback()
474 static int nci_open_device(struct nci_dev *ndev) in nci_open_device() argument
478 mutex_lock(&ndev->req_lock); in nci_open_device()
480 if (test_bit(NCI_UNREG, &ndev->flags)) { in nci_open_device()
485 if (test_bit(NCI_UP, &ndev->flags)) { in nci_open_device()
490 if (ndev->ops->open(ndev)) { in nci_open_device()
495 atomic_set(&ndev->cmd_cnt, 1); in nci_open_device()
497 set_bit(NCI_INIT, &ndev->flags); in nci_open_device()
499 if (ndev->ops->init) in nci_open_device()
500 rc = ndev->ops->init(ndev); in nci_open_device()
503 rc = __nci_request(ndev, nci_reset_req, (void *)0, in nci_open_device()
507 if (!rc && ndev->ops->setup) { in nci_open_device()
508 rc = ndev->ops->setup(ndev); in nci_open_device()
518 if (ndev->nci_ver & NCI_VER_2_MASK) in nci_open_device()
521 rc = __nci_request(ndev, nci_init_req, opt, in nci_open_device()
525 if (!rc && ndev->ops->post_setup) in nci_open_device()
526 rc = ndev->ops->post_setup(ndev); in nci_open_device()
529 rc = __nci_request(ndev, nci_init_complete_req, (void *)0, in nci_open_device()
533 clear_bit(NCI_INIT, &ndev->flags); in nci_open_device()
536 set_bit(NCI_UP, &ndev->flags); in nci_open_device()
537 nci_clear_target_list(ndev); in nci_open_device()
538 atomic_set(&ndev->state, NCI_IDLE); in nci_open_device()
541 skb_queue_purge(&ndev->cmd_q); in nci_open_device()
542 skb_queue_purge(&ndev->rx_q); in nci_open_device()
543 skb_queue_purge(&ndev->tx_q); in nci_open_device()
545 ndev->ops->close(ndev); in nci_open_device()
546 ndev->flags &= BIT(NCI_UNREG); in nci_open_device()
550 mutex_unlock(&ndev->req_lock); in nci_open_device()
554 static int nci_close_device(struct nci_dev *ndev) in nci_close_device() argument
556 nci_req_cancel(ndev, ENODEV); in nci_close_device()
561 mutex_lock(&ndev->req_lock); in nci_close_device()
563 if (!test_and_clear_bit(NCI_UP, &ndev->flags)) { in nci_close_device()
567 flush_workqueue(ndev->cmd_wq); in nci_close_device()
568 del_timer_sync(&ndev->cmd_timer); in nci_close_device()
569 del_timer_sync(&ndev->data_timer); in nci_close_device()
570 mutex_unlock(&ndev->req_lock); in nci_close_device()
575 skb_queue_purge(&ndev->rx_q); in nci_close_device()
576 skb_queue_purge(&ndev->tx_q); in nci_close_device()
579 flush_workqueue(ndev->rx_wq); in nci_close_device()
580 flush_workqueue(ndev->tx_wq); in nci_close_device()
583 skb_queue_purge(&ndev->cmd_q); in nci_close_device()
584 atomic_set(&ndev->cmd_cnt, 1); in nci_close_device()
586 set_bit(NCI_INIT, &ndev->flags); in nci_close_device()
587 __nci_request(ndev, nci_reset_req, (void *)0, in nci_close_device()
593 ndev->ops->close(ndev); in nci_close_device()
595 clear_bit(NCI_INIT, &ndev->flags); in nci_close_device()
598 flush_workqueue(ndev->cmd_wq); in nci_close_device()
600 del_timer_sync(&ndev->cmd_timer); in nci_close_device()
603 ndev->flags &= BIT(NCI_UNREG); in nci_close_device()
605 mutex_unlock(&ndev->req_lock); in nci_close_device()
613 struct nci_dev *ndev = from_timer(ndev, t, cmd_timer); in nci_cmd_timer() local
615 atomic_set(&ndev->cmd_cnt, 1); in nci_cmd_timer()
616 queue_work(ndev->cmd_wq, &ndev->cmd_work); in nci_cmd_timer()
622 struct nci_dev *ndev = from_timer(ndev, t, data_timer); in nci_data_timer() local
624 set_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags); in nci_data_timer()
625 queue_work(ndev->rx_wq, &ndev->rx_work); in nci_data_timer()
630 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_dev_up() local
632 return nci_open_device(ndev); in nci_dev_up()
637 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_dev_down() local
639 return nci_close_device(ndev); in nci_dev_down()
642 int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, const __u8 *val) in nci_set_config() argument
653 return __nci_request(ndev, nci_set_config_req, ¶m, in nci_set_config()
658 static void nci_nfcee_discover_req(struct nci_dev *ndev, const void *opt) in nci_nfcee_discover_req() argument
665 nci_send_cmd(ndev, NCI_OP_NFCEE_DISCOVER_CMD, 1, &cmd); in nci_nfcee_discover_req()
668 int nci_nfcee_discover(struct nci_dev *ndev, u8 action) in nci_nfcee_discover() argument
672 return __nci_request(ndev, nci_nfcee_discover_req, (void *)opt, in nci_nfcee_discover()
677 static void nci_nfcee_mode_set_req(struct nci_dev *ndev, const void *opt) in nci_nfcee_mode_set_req() argument
681 nci_send_cmd(ndev, NCI_OP_NFCEE_MODE_SET_CMD, in nci_nfcee_mode_set_req()
685 int nci_nfcee_mode_set(struct nci_dev *ndev, u8 nfcee_id, u8 nfcee_mode) in nci_nfcee_mode_set() argument
692 return __nci_request(ndev, nci_nfcee_mode_set_req, &cmd, in nci_nfcee_mode_set()
697 static void nci_core_conn_create_req(struct nci_dev *ndev, const void *opt) in nci_core_conn_create_req() argument
701 nci_send_cmd(ndev, NCI_OP_CORE_CONN_CREATE_CMD, data->length, data->cmd); in nci_core_conn_create_req()
704 int nci_core_conn_create(struct nci_dev *ndev, u8 destination_type, in nci_core_conn_create() argument
726 memcpy(&ndev->cur_params, in nci_core_conn_create()
730 ndev->cur_params.id = 0; in nci_core_conn_create()
732 ndev->cur_params.id = 0; in nci_core_conn_create()
734 ndev->cur_dest_type = destination_type; in nci_core_conn_create()
736 r = __nci_request(ndev, nci_core_conn_create_req, &data, in nci_core_conn_create()
743 static void nci_core_conn_close_req(struct nci_dev *ndev, const void *opt) in nci_core_conn_close_req() argument
747 nci_send_cmd(ndev, NCI_OP_CORE_CONN_CLOSE_CMD, 1, &conn_id); in nci_core_conn_close_req()
750 int nci_core_conn_close(struct nci_dev *ndev, u8 conn_id) in nci_core_conn_close() argument
754 ndev->cur_conn_id = conn_id; in nci_core_conn_close()
755 return __nci_request(ndev, nci_core_conn_close_req, (void *)opt, in nci_core_conn_close()
762 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_set_local_general_bytes() local
775 rc = nci_request(ndev, nci_set_config_req, ¶m, in nci_set_local_general_bytes()
782 return nci_request(ndev, nci_set_config_req, ¶m, in nci_set_local_general_bytes()
788 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_set_listen_parameters() local
794 rc = nci_set_config(ndev, NCI_LA_SEL_INFO, 1, &val); in nci_set_listen_parameters()
800 rc = nci_set_config(ndev, NCI_LF_PROTOCOL_TYPE, 1, &val); in nci_set_listen_parameters()
806 return nci_set_config(ndev, NCI_LF_CON_BITR_F, 1, &val); in nci_set_listen_parameters()
812 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_start_poll() local
816 if ((atomic_read(&ndev->state) == NCI_DISCOVERY) || in nci_start_poll()
817 (atomic_read(&ndev->state) == NCI_W4_ALL_DISCOVERIES)) { in nci_start_poll()
822 if (ndev->target_active_prot) { in nci_start_poll()
827 if ((atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) || in nci_start_poll()
828 (atomic_read(&ndev->state) == NCI_POLL_ACTIVE)) { in nci_start_poll()
831 rc = nci_request(ndev, nci_rf_deactivate_req, in nci_start_poll()
854 rc = nci_request(ndev, nci_rf_discover_req, ¶m, in nci_start_poll()
858 ndev->poll_prots = im_protocols; in nci_start_poll()
865 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_stop_poll() local
867 if ((atomic_read(&ndev->state) != NCI_DISCOVERY) && in nci_stop_poll()
868 (atomic_read(&ndev->state) != NCI_W4_ALL_DISCOVERIES)) { in nci_stop_poll()
873 nci_request(ndev, nci_rf_deactivate_req, in nci_stop_poll()
881 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_activate_target() local
889 if ((atomic_read(&ndev->state) != NCI_W4_HOST_SELECT) && in nci_activate_target()
890 (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) { in nci_activate_target()
895 if (ndev->target_active_prot) { in nci_activate_target()
900 for (i = 0; i < ndev->n_targets; i++) { in nci_activate_target()
901 if (ndev->targets[i].idx == target->idx) { in nci_activate_target()
902 nci_target = &ndev->targets[i]; in nci_activate_target()
923 if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) { in nci_activate_target()
938 rc = nci_request(ndev, nci_rf_discover_select_req, ¶m, in nci_activate_target()
943 ndev->target_active_prot = protocol; in nci_activate_target()
952 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_deactivate_target() local
955 if (!ndev->target_active_prot) { in nci_deactivate_target()
960 ndev->target_active_prot = 0; in nci_deactivate_target()
968 if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) { in nci_deactivate_target()
969 nci_request(ndev, nci_rf_deactivate_req, (void *)nci_mode, in nci_deactivate_target()
977 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_dep_link_up() local
986 rc = nfc_set_remote_general_bytes(nfc_dev, ndev->remote_gb, in nci_dep_link_up()
987 ndev->remote_gb_len); in nci_dep_link_up()
997 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_dep_link_down() local
1003 if (atomic_read(&ndev->state) == NCI_LISTEN_ACTIVE || in nci_dep_link_down()
1004 atomic_read(&ndev->state) == NCI_DISCOVERY) { in nci_dep_link_down()
1005 nci_request(ndev, nci_rf_deactivate_req, (void *)0, in nci_dep_link_down()
1022 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_transceive() local
1026 conn_info = ndev->rf_conn_info; in nci_transceive()
1032 if (!ndev->target_active_prot) { in nci_transceive()
1037 if (test_and_set_bit(NCI_DATA_EXCHANGE, &ndev->flags)) in nci_transceive()
1044 rc = nci_send_data(ndev, NCI_STATIC_RF_CONN_ID, skb); in nci_transceive()
1046 clear_bit(NCI_DATA_EXCHANGE, &ndev->flags); in nci_transceive()
1053 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_tm_send() local
1056 rc = nci_send_data(ndev, NCI_STATIC_RF_CONN_ID, skb); in nci_tm_send()
1065 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_enable_se() local
1067 if (ndev->ops->enable_se) in nci_enable_se()
1068 return ndev->ops->enable_se(ndev, se_idx); in nci_enable_se()
1075 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_disable_se() local
1077 if (ndev->ops->disable_se) in nci_disable_se()
1078 return ndev->ops->disable_se(ndev, se_idx); in nci_disable_se()
1086 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_discover_se() local
1088 if (ndev->ops->discover_se) { in nci_discover_se()
1089 r = nci_nfcee_discover(ndev, NCI_NFCEE_DISCOVERY_ACTION_ENABLE); in nci_discover_se()
1093 return ndev->ops->discover_se(ndev); in nci_discover_se()
1103 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_se_io() local
1105 if (ndev->ops->se_io) in nci_se_io()
1106 return ndev->ops->se_io(ndev, se_idx, apdu, in nci_se_io()
1114 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); in nci_fw_download() local
1116 if (!ndev->ops->fw_download) in nci_fw_download()
1119 return ndev->ops->fw_download(ndev, firmware_name); in nci_fw_download()
1153 struct nci_dev *ndev; in nci_allocate_device() local
1163 ndev = kzalloc(sizeof(struct nci_dev), GFP_KERNEL); in nci_allocate_device()
1164 if (!ndev) in nci_allocate_device()
1167 ndev->ops = ops; in nci_allocate_device()
1175 ndev->tx_headroom = tx_headroom; in nci_allocate_device()
1176 ndev->tx_tailroom = tx_tailroom; in nci_allocate_device()
1177 init_completion(&ndev->req_completion); in nci_allocate_device()
1179 ndev->nfc_dev = nfc_allocate_device(&nci_nfc_ops, in nci_allocate_device()
1183 if (!ndev->nfc_dev) in nci_allocate_device()
1186 ndev->hci_dev = nci_hci_allocate(ndev); in nci_allocate_device()
1187 if (!ndev->hci_dev) in nci_allocate_device()
1190 nfc_set_drvdata(ndev->nfc_dev, ndev); in nci_allocate_device()
1192 return ndev; in nci_allocate_device()
1195 nfc_free_device(ndev->nfc_dev); in nci_allocate_device()
1197 kfree(ndev); in nci_allocate_device()
1205 * @ndev: The nci device to deallocate
1207 void nci_free_device(struct nci_dev *ndev) in nci_free_device() argument
1209 nfc_free_device(ndev->nfc_dev); in nci_free_device()
1210 nci_hci_deallocate(ndev); in nci_free_device()
1213 if (ndev->rx_data_reassembly) in nci_free_device()
1214 kfree_skb(ndev->rx_data_reassembly); in nci_free_device()
1215 kfree(ndev); in nci_free_device()
1222 * @ndev: The nci device to register
1224 int nci_register_device(struct nci_dev *ndev) in nci_register_device() argument
1227 struct device *dev = &ndev->nfc_dev->dev; in nci_register_device()
1230 ndev->flags = 0; in nci_register_device()
1232 INIT_WORK(&ndev->cmd_work, nci_cmd_work); in nci_register_device()
1234 ndev->cmd_wq = create_singlethread_workqueue(name); in nci_register_device()
1235 if (!ndev->cmd_wq) { in nci_register_device()
1240 INIT_WORK(&ndev->rx_work, nci_rx_work); in nci_register_device()
1242 ndev->rx_wq = create_singlethread_workqueue(name); in nci_register_device()
1243 if (!ndev->rx_wq) { in nci_register_device()
1248 INIT_WORK(&ndev->tx_work, nci_tx_work); in nci_register_device()
1250 ndev->tx_wq = create_singlethread_workqueue(name); in nci_register_device()
1251 if (!ndev->tx_wq) { in nci_register_device()
1256 skb_queue_head_init(&ndev->cmd_q); in nci_register_device()
1257 skb_queue_head_init(&ndev->rx_q); in nci_register_device()
1258 skb_queue_head_init(&ndev->tx_q); in nci_register_device()
1260 timer_setup(&ndev->cmd_timer, nci_cmd_timer, 0); in nci_register_device()
1261 timer_setup(&ndev->data_timer, nci_data_timer, 0); in nci_register_device()
1263 mutex_init(&ndev->req_lock); in nci_register_device()
1264 INIT_LIST_HEAD(&ndev->conn_info_list); in nci_register_device()
1266 rc = nfc_register_device(ndev->nfc_dev); in nci_register_device()
1273 destroy_workqueue(ndev->tx_wq); in nci_register_device()
1276 destroy_workqueue(ndev->rx_wq); in nci_register_device()
1279 destroy_workqueue(ndev->cmd_wq); in nci_register_device()
1289 * @ndev: The nci device to unregister
1291 void nci_unregister_device(struct nci_dev *ndev) in nci_unregister_device() argument
1296 * However, it is fine because the mutex_lock(&ndev->req_lock); in nci_unregister_device()
1299 set_bit(NCI_UNREG, &ndev->flags); in nci_unregister_device()
1301 nci_close_device(ndev); in nci_unregister_device()
1303 destroy_workqueue(ndev->cmd_wq); in nci_unregister_device()
1304 destroy_workqueue(ndev->rx_wq); in nci_unregister_device()
1305 destroy_workqueue(ndev->tx_wq); in nci_unregister_device()
1307 list_for_each_entry_safe(conn_info, n, &ndev->conn_info_list, list) { in nci_unregister_device()
1312 nfc_unregister_device(ndev->nfc_dev); in nci_unregister_device()
1319 * @ndev: The nci device
1322 int nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb) in nci_recv_frame() argument
1326 if (!ndev || (!test_bit(NCI_UP, &ndev->flags) && in nci_recv_frame()
1327 !test_bit(NCI_INIT, &ndev->flags))) { in nci_recv_frame()
1333 skb_queue_tail(&ndev->rx_q, skb); in nci_recv_frame()
1334 queue_work(ndev->rx_wq, &ndev->rx_work); in nci_recv_frame()
1340 int nci_send_frame(struct nci_dev *ndev, struct sk_buff *skb) in nci_send_frame() argument
1344 if (!ndev) { in nci_send_frame()
1353 nfc_send_to_raw_sock(ndev->nfc_dev, skb, in nci_send_frame()
1356 return ndev->ops->send(ndev, skb); in nci_send_frame()
1361 int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, const void *payload) in nci_send_cmd() argument
1368 skb = nci_skb_alloc(ndev, (NCI_CTRL_HDR_SIZE + plen), GFP_KERNEL); in nci_send_cmd()
1385 skb_queue_tail(&ndev->cmd_q, skb); in nci_send_cmd()
1386 queue_work(ndev->cmd_wq, &ndev->cmd_work); in nci_send_cmd()
1412 static int nci_op_rsp_packet(struct nci_dev *ndev, __u16 rsp_opcode, in nci_op_rsp_packet() argument
1422 return op->rsp(ndev, skb); in nci_op_rsp_packet()
1425 static int nci_op_ntf_packet(struct nci_dev *ndev, __u16 ntf_opcode, in nci_op_ntf_packet() argument
1435 return op->ntf(ndev, skb); in nci_op_ntf_packet()
1438 int nci_prop_rsp_packet(struct nci_dev *ndev, __u16 opcode, in nci_prop_rsp_packet() argument
1441 return nci_op_rsp_packet(ndev, opcode, skb, ndev->ops->prop_ops, in nci_prop_rsp_packet()
1442 ndev->ops->n_prop_ops); in nci_prop_rsp_packet()
1445 int nci_prop_ntf_packet(struct nci_dev *ndev, __u16 opcode, in nci_prop_ntf_packet() argument
1448 return nci_op_ntf_packet(ndev, opcode, skb, ndev->ops->prop_ops, in nci_prop_ntf_packet()
1449 ndev->ops->n_prop_ops); in nci_prop_ntf_packet()
1452 int nci_core_rsp_packet(struct nci_dev *ndev, __u16 opcode, in nci_core_rsp_packet() argument
1455 return nci_op_rsp_packet(ndev, opcode, skb, ndev->ops->core_ops, in nci_core_rsp_packet()
1456 ndev->ops->n_core_ops); in nci_core_rsp_packet()
1459 int nci_core_ntf_packet(struct nci_dev *ndev, __u16 opcode, in nci_core_ntf_packet() argument
1462 return nci_op_ntf_packet(ndev, opcode, skb, ndev->ops->core_ops, in nci_core_ntf_packet()
1463 ndev->ops->n_core_ops); in nci_core_ntf_packet()
1483 struct nci_dev *ndev = container_of(work, struct nci_dev, tx_work); in nci_tx_work() local
1487 conn_info = nci_get_conn_info_by_conn_id(ndev, ndev->cur_conn_id); in nci_tx_work()
1495 skb = skb_dequeue(&ndev->tx_q); in nci_tx_work()
1510 nci_send_frame(ndev, skb); in nci_tx_work()
1512 mod_timer(&ndev->data_timer, in nci_tx_work()
1522 struct nci_dev *ndev = container_of(work, struct nci_dev, rx_work); in nci_rx_work() local
1525 for (; (skb = skb_dequeue(&ndev->rx_q)); kcov_remote_stop()) { in nci_rx_work()
1529 nfc_send_to_raw_sock(ndev->nfc_dev, skb, in nci_rx_work()
1540 nci_rsp_packet(ndev, skb); in nci_rx_work()
1544 nci_ntf_packet(ndev, skb); in nci_rx_work()
1548 nci_rx_data_packet(ndev, skb); in nci_rx_work()
1559 if (test_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags)) { in nci_rx_work()
1561 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) in nci_rx_work()
1562 nci_data_exchange_complete(ndev, NULL, in nci_rx_work()
1563 ndev->cur_conn_id, in nci_rx_work()
1566 clear_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags); in nci_rx_work()
1574 struct nci_dev *ndev = container_of(work, struct nci_dev, cmd_work); in nci_cmd_work() local
1577 pr_debug("cmd_cnt %d\n", atomic_read(&ndev->cmd_cnt)); in nci_cmd_work()
1580 if (atomic_read(&ndev->cmd_cnt)) { in nci_cmd_work()
1581 skb = skb_dequeue(&ndev->cmd_q); in nci_cmd_work()
1586 atomic_dec(&ndev->cmd_cnt); in nci_cmd_work()
1594 nci_send_frame(ndev, skb); in nci_cmd_work()
1596 mod_timer(&ndev->cmd_timer, in nci_cmd_work()