Commit e4c4789e authored by Eric Lapuyade's avatar Eric Lapuyade Committed by Samuel Ortiz

NFC: Add a public nfc_hci_send_cmd_async method

This method initiates execution of an HCI cmd. Result will be delivered
through an asynchronous callback.
Signed-off-by: default avatarEric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent b5faa648
...@@ -200,6 +200,9 @@ int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx, ...@@ -200,6 +200,9 @@ int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx,
const u8 *param, size_t param_len); const u8 *param, size_t param_len);
int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd, int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
const u8 *param, size_t param_len, struct sk_buff **skb); const u8 *param, size_t param_len, struct sk_buff **skb);
int nfc_hci_send_cmd_async(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
const u8 *param, size_t param_len,
data_exchange_cb_t cb, void *cb_context);
int nfc_hci_send_response(struct nfc_hci_dev *hdev, u8 gate, u8 response, int nfc_hci_send_response(struct nfc_hci_dev *hdev, u8 gate, u8 response,
const u8 *param, size_t param_len); const u8 *param, size_t param_len);
int nfc_hci_send_event(struct nfc_hci_dev *hdev, u8 gate, u8 event, int nfc_hci_send_event(struct nfc_hci_dev *hdev, u8 gate, u8 event,
......
...@@ -28,6 +28,20 @@ ...@@ -28,6 +28,20 @@
#include "hci.h" #include "hci.h"
static int nfc_hci_execute_cmd_async(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd,
const u8 *param, size_t param_len,
data_exchange_cb_t cb, void *cb_context)
{
pr_debug("exec cmd async through pipe=%d, cmd=%d, plen=%zd\n", pipe,
cmd, param_len);
/* TODO: Define hci cmd execution delay. Should it be the same
* for all commands?
*/
return nfc_hci_hcp_message_tx(hdev, pipe, NFC_HCI_HCP_COMMAND, cmd,
param, param_len, cb, cb_context, 3000);
}
/* /*
* HCI command execution completion callback. * HCI command execution completion callback.
* err will be a standard linux error (may be converted from HCI response) * err will be a standard linux error (may be converted from HCI response)
...@@ -60,7 +74,8 @@ static int nfc_hci_execute_cmd(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, ...@@ -60,7 +74,8 @@ static int nfc_hci_execute_cmd(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd,
hcp_ew.exec_complete = false; hcp_ew.exec_complete = false;
hcp_ew.result_skb = NULL; hcp_ew.result_skb = NULL;
pr_debug("through pipe=%d, cmd=%d, plen=%zd\n", pipe, cmd, param_len); pr_debug("exec cmd sync through pipe=%d, cmd=%d, plen=%zd\n", pipe,
cmd, param_len);
/* TODO: Define hci cmd execution delay. Should it be the same /* TODO: Define hci cmd execution delay. Should it be the same
* for all commands? * for all commands?
...@@ -138,6 +153,23 @@ int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd, ...@@ -138,6 +153,23 @@ int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
} }
EXPORT_SYMBOL(nfc_hci_send_cmd); EXPORT_SYMBOL(nfc_hci_send_cmd);
int nfc_hci_send_cmd_async(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
const u8 *param, size_t param_len,
data_exchange_cb_t cb, void *cb_context)
{
u8 pipe;
pr_debug("\n");
pipe = hdev->gate2pipe[gate];
if (pipe == NFC_HCI_INVALID_PIPE)
return -EADDRNOTAVAIL;
return nfc_hci_execute_cmd_async(hdev, pipe, cmd, param, param_len,
cb, cb_context);
}
EXPORT_SYMBOL(nfc_hci_send_cmd_async);
int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx, int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx,
const u8 *param, size_t param_len) const u8 *param, size_t param_len)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment