summaryrefslogtreecommitdiffstats
path: root/net/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 /net/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 'net/nfc')
-rw-r--r--net/nfc/nci/core.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 17ff5f83393c..ddfe91e43c88 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -41,6 +41,11 @@
41#include <net/nfc/nci_core.h> 41#include <net/nfc/nci_core.h>
42#include <linux/nfc.h> 42#include <linux/nfc.h>
43 43
44struct core_conn_create_data {
45 int length;
46 struct nci_core_conn_create_cmd *cmd;
47};
48
44static void nci_cmd_work(struct work_struct *work); 49static void nci_cmd_work(struct work_struct *work);
45static void nci_rx_work(struct work_struct *work); 50static void nci_rx_work(struct work_struct *work);
46static void nci_tx_work(struct work_struct *work); 51static void nci_tx_work(struct work_struct *work);
@@ -509,25 +514,38 @@ EXPORT_SYMBOL(nci_nfcee_mode_set);
509 514
510static void nci_core_conn_create_req(struct nci_dev *ndev, unsigned long opt) 515static void nci_core_conn_create_req(struct nci_dev *ndev, unsigned long opt)
511{ 516{
512 struct nci_core_conn_create_cmd cmd; 517 struct core_conn_create_data *data =
513 struct core_conn_create_dest_spec_params *params = 518 (struct core_conn_create_data *)opt;
514 (struct core_conn_create_dest_spec_params *)opt; 519
515 520 nci_send_cmd(ndev, NCI_OP_CORE_CONN_CREATE_CMD, data->length, data->cmd);
516 cmd.destination_type = NCI_DESTINATION_NFCEE;
517 cmd.number_destination_params = 1;
518 memcpy(&cmd.params.type, params,
519 sizeof(struct core_conn_create_dest_spec_params));
520 nci_send_cmd(ndev, NCI_OP_CORE_CONN_CREATE_CMD,
521 sizeof(struct nci_core_conn_create_cmd), &cmd);
522} 521}
523 522
524int nci_core_conn_create(struct nci_dev *ndev, 523int nci_core_conn_create(struct nci_dev *ndev, u8 destination_type,
524 u8 number_destination_params,
525 size_t params_len,
525 struct core_conn_create_dest_spec_params *params) 526 struct core_conn_create_dest_spec_params *params)
526{ 527{
527 ndev->cur_id = params->value.id; 528 int r;
528 return nci_request(ndev, nci_core_conn_create_req, 529 struct nci_core_conn_create_cmd *cmd;
529 (unsigned long)params, 530 struct core_conn_create_data data;
530 msecs_to_jiffies(NCI_CMD_TIMEOUT)); 531
532 data.length = params_len + sizeof(struct nci_core_conn_create_cmd);
533 cmd = kzalloc(data.length, GFP_KERNEL);
534 if (!cmd)
535 return -ENOMEM;
536
537 cmd->destination_type = destination_type;
538 cmd->number_destination_params = number_destination_params;
539 memcpy(cmd->params, params, params_len);
540
541 data.cmd = cmd;
542 ndev->cur_id = params->value[DEST_SPEC_PARAMS_ID_INDEX];
543
544 r = __nci_request(ndev, nci_core_conn_create_req,
545 (unsigned long)&data,
546 msecs_to_jiffies(NCI_CMD_TIMEOUT));
547 kfree(cmd);
548 return r;
531} 549}
532EXPORT_SYMBOL(nci_core_conn_create); 550EXPORT_SYMBOL(nci_core_conn_create);
533 551