Skip to content

Commit e4c4789

Browse files
Eric LapuyadeSamuel Ortiz
authored andcommitted
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: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent b5faa64 commit e4c4789

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎include/net/nfc/hci.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx,
200200
const u8 *param, size_t param_len);
201201
int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
202202
const u8 *param, size_t param_len, struct sk_buff **skb);
203+
int nfc_hci_send_cmd_async(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
204+
const u8 *param, size_t param_len,
205+
data_exchange_cb_t cb, void *cb_context);
203206
int nfc_hci_send_response(struct nfc_hci_dev *hdev, u8 gate, u8 response,
204207
const u8 *param, size_t param_len);
205208
int nfc_hci_send_event(struct nfc_hci_dev *hdev, u8 gate, u8 event,

‎net/nfc/hci/command.c‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828

2929
#include "hci.h"
3030

31+
static int nfc_hci_execute_cmd_async(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd,
32+
const u8 *param, size_t param_len,
33+
data_exchange_cb_t cb, void *cb_context)
34+
{
35+
pr_debug("exec cmd async through pipe=%d, cmd=%d, plen=%zd\n", pipe,
36+
cmd, param_len);
37+
38+
/* TODO: Define hci cmd execution delay. Should it be the same
39+
* for all commands?
40+
*/
41+
return nfc_hci_hcp_message_tx(hdev, pipe, NFC_HCI_HCP_COMMAND, cmd,
42+
param, param_len, cb, cb_context, 3000);
43+
}
44+
3145
/*
3246
* HCI command execution completion callback.
3347
* 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,
6074
hcp_ew.exec_complete = false;
6175
hcp_ew.result_skb = NULL;
6276

63-
pr_debug("through pipe=%d, cmd=%d, plen=%zd\n", pipe, cmd, param_len);
77+
pr_debug("exec cmd sync through pipe=%d, cmd=%d, plen=%zd\n", pipe,
78+
cmd, param_len);
6479

6580
/* TODO: Define hci cmd execution delay. Should it be the same
6681
* for all commands?
@@ -138,6 +153,23 @@ int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
138153
}
139154
EXPORT_SYMBOL(nfc_hci_send_cmd);
140155

156+
int nfc_hci_send_cmd_async(struct nfc_hci_dev *hdev, u8 gate, u8 cmd,
157+
const u8 *param, size_t param_len,
158+
data_exchange_cb_t cb, void *cb_context)
159+
{
160+
u8 pipe;
161+
162+
pr_debug("\n");
163+
164+
pipe = hdev->gate2pipe[gate];
165+
if (pipe == NFC_HCI_INVALID_PIPE)
166+
return -EADDRNOTAVAIL;
167+
168+
return nfc_hci_execute_cmd_async(hdev, pipe, cmd, param, param_len,
169+
cb, cb_context);
170+
}
171+
EXPORT_SYMBOL(nfc_hci_send_cmd_async);
172+
141173
int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx,
142174
const u8 *param, size_t param_len)
143175
{

0 commit comments

Comments
 (0)