Commit b5faa648 authored by Eric Lapuyade's avatar Eric Lapuyade Committed by Samuel Ortiz

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: default avatarEric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent c1be2117
...@@ -28,10 +28,15 @@ ...@@ -28,10 +28,15 @@
#include "hci.h" #include "hci.h"
static void nfc_hci_execute_cb(struct nfc_hci_dev *hdev, int err, /*
struct sk_buff *skb, void *cb_data) * HCI command execution completion callback.
* err will be a standard linux error (may be converted from HCI response)
* skb contains the response data and must be disposed, or may be NULL if
* an error occured
*/
static void nfc_hci_execute_cb(void *context, struct sk_buff *skb, int err)
{ {
struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)cb_data; struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)context;
pr_debug("HCI Cmd completed with result=%d\n", err); pr_debug("HCI Cmd completed with result=%d\n", err);
......
...@@ -57,12 +57,11 @@ static void nfc_hci_msg_tx_work(struct work_struct *work) ...@@ -57,12 +57,11 @@ static void nfc_hci_msg_tx_work(struct work_struct *work)
if (hdev->cmd_pending_msg) { if (hdev->cmd_pending_msg) {
if (timer_pending(&hdev->cmd_timer) == 0) { if (timer_pending(&hdev->cmd_timer) == 0) {
if (hdev->cmd_pending_msg->cb) if (hdev->cmd_pending_msg->cb)
hdev->cmd_pending_msg->cb(hdev, hdev->cmd_pending_msg->cb(hdev->
-ETIME,
NULL,
hdev->
cmd_pending_msg-> cmd_pending_msg->
cb_context); cb_context,
NULL,
-ETIME);
kfree(hdev->cmd_pending_msg); kfree(hdev->cmd_pending_msg);
hdev->cmd_pending_msg = NULL; hdev->cmd_pending_msg = NULL;
} else } else
...@@ -83,7 +82,7 @@ static void nfc_hci_msg_tx_work(struct work_struct *work) ...@@ -83,7 +82,7 @@ static void nfc_hci_msg_tx_work(struct work_struct *work)
kfree_skb(skb); kfree_skb(skb);
skb_queue_purge(&msg->msg_frags); skb_queue_purge(&msg->msg_frags);
if (msg->cb) if (msg->cb)
msg->cb(hdev, r, NULL, msg->cb_context); msg->cb(msg->cb_context, NULL, r);
kfree(msg); kfree(msg);
break; break;
} }
...@@ -133,8 +132,8 @@ static void __nfc_hci_cmd_completion(struct nfc_hci_dev *hdev, int err, ...@@ -133,8 +132,8 @@ static void __nfc_hci_cmd_completion(struct nfc_hci_dev *hdev, int err,
del_timer_sync(&hdev->cmd_timer); del_timer_sync(&hdev->cmd_timer);
if (hdev->cmd_pending_msg->cb) if (hdev->cmd_pending_msg->cb)
hdev->cmd_pending_msg->cb(hdev, err, skb, hdev->cmd_pending_msg->cb(hdev->cmd_pending_msg->cb_context,
hdev->cmd_pending_msg->cb_context); skb, err);
else else
kfree_skb(skb); kfree_skb(skb);
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#ifndef __LOCAL_HCI_H #ifndef __LOCAL_HCI_H
#define __LOCAL_HCI_H #define __LOCAL_HCI_H
#include <net/nfc/hci.h>
struct gate_pipe_map { struct gate_pipe_map {
u8 gate; u8 gate;
u8 pipe; u8 pipe;
...@@ -35,15 +37,6 @@ struct hcp_packet { ...@@ -35,15 +37,6 @@ struct hcp_packet {
struct hcp_message message; struct hcp_message message;
} __packed; } __packed;
/*
* HCI command execution completion callback.
* result will be a standard linux error (may be converted from HCI response)
* skb contains the response data and must be disposed, or may be NULL if
* an error occured
*/
typedef void (*hci_cmd_cb_t) (struct nfc_hci_dev *hdev, int result,
struct sk_buff *skb, void *cb_data);
struct hcp_exec_waiter { struct hcp_exec_waiter {
wait_queue_head_t *wq; wait_queue_head_t *wq;
bool exec_complete; bool exec_complete;
...@@ -55,7 +48,7 @@ struct hci_msg { ...@@ -55,7 +48,7 @@ struct hci_msg {
struct list_head msg_l; struct list_head msg_l;
struct sk_buff_head msg_frags; struct sk_buff_head msg_frags;
bool wait_response; bool wait_response;
hci_cmd_cb_t cb; data_exchange_cb_t cb;
void *cb_context; void *cb_context;
unsigned long completion_delay; unsigned long completion_delay;
}; };
...@@ -83,7 +76,7 @@ struct hci_create_pipe_resp { ...@@ -83,7 +76,7 @@ struct hci_create_pipe_resp {
int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe, int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
u8 type, u8 instruction, u8 type, u8 instruction,
const u8 *payload, size_t payload_len, const u8 *payload, size_t payload_len,
hci_cmd_cb_t cb, void *cb_data, data_exchange_cb_t cb, void *cb_context,
unsigned long completion_delay); unsigned long completion_delay);
u8 nfc_hci_pipe2gate(struct nfc_hci_dev *hdev, u8 pipe); u8 nfc_hci_pipe2gate(struct nfc_hci_dev *hdev, u8 pipe);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe, int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
u8 type, u8 instruction, u8 type, u8 instruction,
const u8 *payload, size_t payload_len, const u8 *payload, size_t payload_len,
hci_cmd_cb_t cb, void *cb_data, data_exchange_cb_t cb, void *cb_context,
unsigned long completion_delay) unsigned long completion_delay)
{ {
struct nfc_dev *ndev = hdev->ndev; struct nfc_dev *ndev = hdev->ndev;
...@@ -52,7 +52,7 @@ int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe, ...@@ -52,7 +52,7 @@ int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
skb_queue_head_init(&cmd->msg_frags); skb_queue_head_init(&cmd->msg_frags);
cmd->wait_response = (type == NFC_HCI_HCP_COMMAND) ? true : false; cmd->wait_response = (type == NFC_HCI_HCP_COMMAND) ? true : false;
cmd->cb = cb; cmd->cb = cb;
cmd->cb_context = cb_data; cmd->cb_context = cb_context;
cmd->completion_delay = completion_delay; cmd->completion_delay = completion_delay;
hci_len = payload_len + 1; hci_len = payload_len + 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment