diff options
author | Eric Lapuyade <eric.lapuyade@linux.intel.com> | 2012-09-11 04:42:54 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-09-24 18:17:25 -0400 |
commit | e4c4789e55327e5f2bd6cafcccd46f9b6251bbc3 (patch) | |
tree | e143a6128fb46578b9634300accece0c9277b56b /net/nfc | |
parent | b5faa648faf974b58e5a79eafa9a97e1deed7a8a (diff) |
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>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/hci/command.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/net/nfc/hci/command.c b/net/nfc/hci/command.c index 15e21093c7a5..71c6a7086b8f 100644 --- a/net/nfc/hci/command.c +++ b/net/nfc/hci/command.c | |||
@@ -28,6 +28,20 @@ | |||
28 | 28 | ||
29 | #include "hci.h" | 29 | #include "hci.h" |
30 | 30 | ||
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 | |||
31 | /* | 45 | /* |
32 | * HCI command execution completion callback. | 46 | * HCI command execution completion callback. |
33 | * err will be a standard linux error (may be converted from HCI response) | 47 | * 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 | hcp_ew.exec_complete = false; | 74 | hcp_ew.exec_complete = false; |
61 | hcp_ew.result_skb = NULL; | 75 | hcp_ew.result_skb = NULL; |
62 | 76 | ||
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); | ||
64 | 79 | ||
65 | /* TODO: Define hci cmd execution delay. Should it be the same | 80 | /* TODO: Define hci cmd execution delay. Should it be the same |
66 | * for all commands? | 81 | * for all commands? |
@@ -138,6 +153,23 @@ int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd, | |||
138 | } | 153 | } |
139 | EXPORT_SYMBOL(nfc_hci_send_cmd); | 154 | EXPORT_SYMBOL(nfc_hci_send_cmd); |
140 | 155 | ||
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 | |||
141 | int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx, | 173 | int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx, |
142 | const u8 *param, size_t param_len) | 174 | const u8 *param, size_t param_len) |
143 | { | 175 | { |