Skip to content

Commit b5faa64

Browse files
Eric LapuyadeSamuel Ortiz
authored andcommitted
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>
1 parent c1be211 commit b5faa64

4 files changed

Lines changed: 21 additions & 24 deletions

File tree

‎net/nfc/hci/command.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@
2828

2929
#include "hci.h"
3030

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)
3338
{
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;
3540

3641
pr_debug("HCI Cmd completed with result=%d\n", err);
3742

‎net/nfc/hci/core.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@ static void nfc_hci_msg_tx_work(struct work_struct *work)
5757
if (hdev->cmd_pending_msg) {
5858
if (timer_pending(&hdev->cmd_timer) == 0) {
5959
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->
6461
cmd_pending_msg->
65-
cb_context);
62+
cb_context,
63+
NULL,
64+
-ETIME);
6665
kfree(hdev->cmd_pending_msg);
6766
hdev->cmd_pending_msg = NULL;
6867
} else
@@ -83,7 +82,7 @@ static void nfc_hci_msg_tx_work(struct work_struct *work)
8382
kfree_skb(skb);
8483
skb_queue_purge(&msg->msg_frags);
8584
if (msg->cb)
86-
msg->cb(hdev, r, NULL, msg->cb_context);
85+
msg->cb(msg->cb_context, NULL, r);
8786
kfree(msg);
8887
break;
8988
}
@@ -133,8 +132,8 @@ static void __nfc_hci_cmd_completion(struct nfc_hci_dev *hdev, int err,
133132
del_timer_sync(&hdev->cmd_timer);
134133

135134
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);
138137
else
139138
kfree_skb(skb);
140139

‎net/nfc/hci/hci.h‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#ifndef __LOCAL_HCI_H
2121
#define __LOCAL_HCI_H
2222

23+
#include <net/nfc/hci.h>
24+
2325
struct gate_pipe_map {
2426
u8 gate;
2527
u8 pipe;
@@ -35,15 +37,6 @@ struct hcp_packet {
3537
struct hcp_message message;
3638
} __packed;
3739

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-
4740
struct hcp_exec_waiter {
4841
wait_queue_head_t *wq;
4942
bool exec_complete;
@@ -55,7 +48,7 @@ struct hci_msg {
5548
struct list_head msg_l;
5649
struct sk_buff_head msg_frags;
5750
bool wait_response;
58-
hci_cmd_cb_t cb;
51+
data_exchange_cb_t cb;
5952
void *cb_context;
6053
unsigned long completion_delay;
6154
};
@@ -83,7 +76,7 @@ struct hci_create_pipe_resp {
8376
int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
8477
u8 type, u8 instruction,
8578
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,
8780
unsigned long completion_delay);
8881

8982
u8 nfc_hci_pipe2gate(struct nfc_hci_dev *hdev, u8 pipe);

‎net/nfc/hci/hcp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
3636
u8 type, u8 instruction,
3737
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,
3939
unsigned long completion_delay)
4040
{
4141
struct nfc_dev *ndev = hdev->ndev;
@@ -52,7 +52,7 @@ int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
5252
skb_queue_head_init(&cmd->msg_frags);
5353
cmd->wait_response = (type == NFC_HCI_HCP_COMMAND) ? true : false;
5454
cmd->cb = cb;
55-
cmd->cb_context = cb_data;
55+
cmd->cb_context = cb_context;
5656
cmd->completion_delay = completion_delay;
5757

5858
hci_len = payload_len + 1;

0 commit comments

Comments
 (0)