diff options
Diffstat (limited to 'net/nfc/hci/command.c')
-rw-r--r-- | net/nfc/hci/command.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/net/nfc/hci/command.c b/net/nfc/hci/command.c index 46362ef979db..71c6a7086b8f 100644 --- a/net/nfc/hci/command.c +++ b/net/nfc/hci/command.c | |||
@@ -28,10 +28,29 @@ | |||
28 | 28 | ||
29 | #include "hci.h" | 29 | #include "hci.h" |
30 | 30 | ||
31 | static void nfc_hci_execute_cb(struct nfc_hci_dev *hdev, int err, | 31 | static int nfc_hci_execute_cmd_async(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, |
32 | struct sk_buff *skb, void *cb_data) | 32 | const u8 *param, size_t param_len, |
33 | data_exchange_cb_t cb, void *cb_context) | ||
33 | { | 34 | { |
34 | struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)cb_data; | 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 | |||
45 | /* | ||
46 | * HCI command execution completion callback. | ||
47 | * err will be a standard linux error (may be converted from HCI response) | ||
48 | * skb contains the response data and must be disposed, or may be NULL if | ||
49 | * an error occured | ||
50 | */ | ||
51 | static void nfc_hci_execute_cb(void *context, struct sk_buff *skb, int err) | ||
52 | { | ||
53 | struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)context; | ||
35 | 54 | ||
36 | pr_debug("HCI Cmd completed with result=%d\n", err); | 55 | pr_debug("HCI Cmd completed with result=%d\n", err); |
37 | 56 | ||
@@ -55,7 +74,8 @@ static int nfc_hci_execute_cmd(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, | |||
55 | hcp_ew.exec_complete = false; | 74 | hcp_ew.exec_complete = false; |
56 | hcp_ew.result_skb = NULL; | 75 | hcp_ew.result_skb = NULL; |
57 | 76 | ||
58 | 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); | ||
59 | 79 | ||
60 | /* TODO: Define hci cmd execution delay. Should it be the same | 80 | /* TODO: Define hci cmd execution delay. Should it be the same |
61 | * for all commands? | 81 | * for all commands? |
@@ -133,6 +153,23 @@ int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd, | |||
133 | } | 153 | } |
134 | EXPORT_SYMBOL(nfc_hci_send_cmd); | 154 | EXPORT_SYMBOL(nfc_hci_send_cmd); |
135 | 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 | |||
136 | 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, |
137 | const u8 *param, size_t param_len) | 174 | const u8 *param, size_t param_len) |
138 | { | 175 | { |