Commit b5faa648faf974b58e5a79eafa9a97e1deed7a8a

Authored by Eric Lapuyade
Committed by Samuel Ortiz
1 parent c1be211727

NFC: Changed the HCI cmd execution callback prototype

Make it match the data_exchange_cb_t so that it can be used directly in
the implementation of an asynchronous hci_transceive

Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

Showing 4 changed files with 21 additions and 24 deletions Side-by-side Diff

net/nfc/hci/command.c
... ... @@ -28,10 +28,15 @@
28 28  
29 29 #include "hci.h"
30 30  
31   -static void nfc_hci_execute_cb(struct nfc_hci_dev *hdev, int err,
32   - struct sk_buff *skb, void *cb_data)
  31 +/*
  32 + * HCI command execution completion callback.
  33 + * err will be a standard linux error (may be converted from HCI response)
  34 + * skb contains the response data and must be disposed, or may be NULL if
  35 + * an error occured
  36 + */
  37 +static void nfc_hci_execute_cb(void *context, struct sk_buff *skb, int err)
33 38 {
34   - struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)cb_data;
  39 + struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)context;
35 40  
36 41 pr_debug("HCI Cmd completed with result=%d\n", err);
37 42  
... ... @@ -57,12 +57,11 @@
57 57 if (hdev->cmd_pending_msg) {
58 58 if (timer_pending(&hdev->cmd_timer) == 0) {
59 59 if (hdev->cmd_pending_msg->cb)
60   - hdev->cmd_pending_msg->cb(hdev,
61   - -ETIME,
62   - NULL,
63   - hdev->
  60 + hdev->cmd_pending_msg->cb(hdev->
64 61 cmd_pending_msg->
65   - cb_context);
  62 + cb_context,
  63 + NULL,
  64 + -ETIME);
66 65 kfree(hdev->cmd_pending_msg);
67 66 hdev->cmd_pending_msg = NULL;
68 67 } else
... ... @@ -83,7 +82,7 @@
83 82 kfree_skb(skb);
84 83 skb_queue_purge(&msg->msg_frags);
85 84 if (msg->cb)
86   - msg->cb(hdev, r, NULL, msg->cb_context);
  85 + msg->cb(msg->cb_context, NULL, r);
87 86 kfree(msg);
88 87 break;
89 88 }
... ... @@ -133,8 +132,8 @@
133 132 del_timer_sync(&hdev->cmd_timer);
134 133  
135 134 if (hdev->cmd_pending_msg->cb)
136   - hdev->cmd_pending_msg->cb(hdev, err, skb,
137   - hdev->cmd_pending_msg->cb_context);
  135 + hdev->cmd_pending_msg->cb(hdev->cmd_pending_msg->cb_context,
  136 + skb, err);
138 137 else
139 138 kfree_skb(skb);
140 139  
... ... @@ -20,6 +20,8 @@
20 20 #ifndef __LOCAL_HCI_H
21 21 #define __LOCAL_HCI_H
22 22  
  23 +#include <net/nfc/hci.h>
  24 +
23 25 struct gate_pipe_map {
24 26 u8 gate;
25 27 u8 pipe;
... ... @@ -35,15 +37,6 @@
35 37 struct hcp_message message;
36 38 } __packed;
37 39  
38   -/*
39   - * HCI command execution completion callback.
40   - * result will be a standard linux error (may be converted from HCI response)
41   - * skb contains the response data and must be disposed, or may be NULL if
42   - * an error occured
43   - */
44   -typedef void (*hci_cmd_cb_t) (struct nfc_hci_dev *hdev, int result,
45   - struct sk_buff *skb, void *cb_data);
46   -
47 40 struct hcp_exec_waiter {
48 41 wait_queue_head_t *wq;
49 42 bool exec_complete;
... ... @@ -55,7 +48,7 @@
55 48 struct list_head msg_l;
56 49 struct sk_buff_head msg_frags;
57 50 bool wait_response;
58   - hci_cmd_cb_t cb;
  51 + data_exchange_cb_t cb;
59 52 void *cb_context;
60 53 unsigned long completion_delay;
61 54 };
... ... @@ -83,7 +76,7 @@
83 76 int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
84 77 u8 type, u8 instruction,
85 78 const u8 *payload, size_t payload_len,
86   - hci_cmd_cb_t cb, void *cb_data,
  79 + data_exchange_cb_t cb, void *cb_context,
87 80 unsigned long completion_delay);
88 81  
89 82 u8 nfc_hci_pipe2gate(struct nfc_hci_dev *hdev, u8 pipe);
... ... @@ -35,7 +35,7 @@
35 35 int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
36 36 u8 type, u8 instruction,
37 37 const u8 *payload, size_t payload_len,
38   - hci_cmd_cb_t cb, void *cb_data,
  38 + data_exchange_cb_t cb, void *cb_context,
39 39 unsigned long completion_delay)
40 40 {
41 41 struct nfc_dev *ndev = hdev->ndev;
... ... @@ -52,7 +52,7 @@
52 52 skb_queue_head_init(&cmd->msg_frags);
53 53 cmd->wait_response = (type == NFC_HCI_HCP_COMMAND) ? true : false;
54 54 cmd->cb = cb;
55   - cmd->cb_context = cb_data;
  55 + cmd->cb_context = cb_context;
56 56 cmd->completion_delay = completion_delay;
57 57  
58 58 hci_len = payload_len + 1;