aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2015-02-03 13:48:05 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2015-02-04 03:10:50 -0500
commitb16ae7160a836c4a1e443ea6efca31421e86bae1 (patch)
tree8d4185e4b41b0d71f5abe293c3183068a129a86c /drivers/nfc
parent12bdf27d46c9d5e490fa164551642e065105db78 (diff)
NFC: nci: Support all destinations type when creating a connection
The current implementation limits nci_core_conn_create_req() to only manage NCI_DESTINATION_NFCEE. Add new parameters to nci_core_conn_create() to support all destination types described in the NCI specification. Because there are some parameters with variable size dynamic buffer allocation is needed. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/st21nfcb/st21nfcb_se.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/drivers/nfc/st21nfcb/st21nfcb_se.c b/drivers/nfc/st21nfcb/st21nfcb_se.c
index 9f4d8b744f32..3b465e4c85e3 100644
--- a/drivers/nfc/st21nfcb/st21nfcb_se.c
+++ b/drivers/nfc/st21nfcb/st21nfcb_se.c
@@ -494,7 +494,8 @@ EXPORT_SYMBOL_GPL(st21nfcb_nci_enable_se);
494 494
495static int st21nfcb_hci_network_init(struct nci_dev *ndev) 495static int st21nfcb_hci_network_init(struct nci_dev *ndev)
496{ 496{
497 struct core_conn_create_dest_spec_params dest_params; 497 struct core_conn_create_dest_spec_params *dest_params;
498 struct dest_spec_params spec_params;
498 struct nci_conn_info *conn_info; 499 struct nci_conn_info *conn_info;
499 int r, dev_num; 500 int r, dev_num;
500 501
@@ -502,17 +503,29 @@ static int st21nfcb_hci_network_init(struct nci_dev *ndev)
502 if (r != NCI_STATUS_OK) 503 if (r != NCI_STATUS_OK)
503 goto exit; 504 goto exit;
504 505
505 dest_params.type = NCI_DESTINATION_SPECIFIC_PARAM_NFCEE_TYPE; 506 dest_params =
506 dest_params.length = sizeof(struct dest_spec_params); 507 kzalloc(sizeof(struct core_conn_create_dest_spec_params) +
507 dest_params.value.id = ndev->hci_dev->conn_info->id; 508 sizeof(struct dest_spec_params), GFP_KERNEL);
508 dest_params.value.protocol = NCI_NFCEE_INTERFACE_HCI_ACCESS; 509 if (dest_params == NULL) {
509 r = nci_core_conn_create(ndev, &dest_params); 510 r = -ENOMEM;
510 if (r != NCI_STATUS_OK)
511 goto exit; 511 goto exit;
512 }
513
514 dest_params->type = NCI_DESTINATION_SPECIFIC_PARAM_NFCEE_TYPE;
515 dest_params->length = sizeof(struct dest_spec_params);
516 spec_params.id = ndev->hci_dev->conn_info->id;
517 spec_params.protocol = NCI_NFCEE_INTERFACE_HCI_ACCESS;
518 memcpy(dest_params->value, &spec_params, sizeof(struct dest_spec_params));
519 r = nci_core_conn_create(ndev, NCI_DESTINATION_NFCEE, 1,
520 sizeof(struct core_conn_create_dest_spec_params) +
521 sizeof(struct dest_spec_params),
522 dest_params);
523 if (r != NCI_STATUS_OK)
524 goto free_dest_params;
512 525
513 conn_info = ndev->hci_dev->conn_info; 526 conn_info = ndev->hci_dev->conn_info;
514 if (!conn_info) 527 if (!conn_info)
515 goto exit; 528 goto free_dest_params;
516 529
517 memcpy(ndev->hci_dev->init_data.gates, st21nfcb_gates, 530 memcpy(ndev->hci_dev->init_data.gates, st21nfcb_gates,
518 sizeof(st21nfcb_gates)); 531 sizeof(st21nfcb_gates));
@@ -522,8 +535,10 @@ static int st21nfcb_hci_network_init(struct nci_dev *ndev)
522 * persistent info to discriminate 2 identical chips 535 * persistent info to discriminate 2 identical chips
523 */ 536 */
524 dev_num = find_first_zero_bit(dev_mask, ST21NFCB_NUM_DEVICES); 537 dev_num = find_first_zero_bit(dev_mask, ST21NFCB_NUM_DEVICES);
525 if (dev_num >= ST21NFCB_NUM_DEVICES) 538 if (dev_num >= ST21NFCB_NUM_DEVICES) {
526 return -ENODEV; 539 r = -ENODEV;
540 goto free_dest_params;
541 }
527 542
528 scnprintf(ndev->hci_dev->init_data.session_id, 543 scnprintf(ndev->hci_dev->init_data.session_id,
529 sizeof(ndev->hci_dev->init_data.session_id), 544 sizeof(ndev->hci_dev->init_data.session_id),
@@ -540,6 +555,9 @@ static int st21nfcb_hci_network_init(struct nci_dev *ndev)
540 555
541 return 0; 556 return 0;
542 557
558free_dest_params:
559 kfree(dest_params);
560
543exit: 561exit:
544 return r; 562 return r;
545} 563}