Skip to content

Commit

Permalink
NFC: Changed the HCI cmd execution callback prototype
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Lapuyade authored and Samuel Ortiz committed Sep 24, 2012
1 parent c1be211 commit b5faa64
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
11 changes: 8 additions & 3 deletions net/nfc/hci/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@

#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);

Expand Down
15 changes: 7 additions & 8 deletions net/nfc/hci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ static void nfc_hci_msg_tx_work(struct work_struct *work)
if (hdev->cmd_pending_msg) {
if (timer_pending(&hdev->cmd_timer) == 0) {
if (hdev->cmd_pending_msg->cb)
hdev->cmd_pending_msg->cb(hdev,
-ETIME,
NULL,
hdev->
hdev->cmd_pending_msg->cb(hdev->
cmd_pending_msg->
cb_context);
cb_context,
NULL,
-ETIME);
kfree(hdev->cmd_pending_msg);
hdev->cmd_pending_msg = NULL;
} else
Expand All @@ -83,7 +82,7 @@ static void nfc_hci_msg_tx_work(struct work_struct *work)
kfree_skb(skb);
skb_queue_purge(&msg->msg_frags);
if (msg->cb)
msg->cb(hdev, r, NULL, msg->cb_context);
msg->cb(msg->cb_context, NULL, r);
kfree(msg);
break;
}
Expand Down Expand Up @@ -133,8 +132,8 @@ static void __nfc_hci_cmd_completion(struct nfc_hci_dev *hdev, int err,
del_timer_sync(&hdev->cmd_timer);

if (hdev->cmd_pending_msg->cb)
hdev->cmd_pending_msg->cb(hdev, err, skb,
hdev->cmd_pending_msg->cb_context);
hdev->cmd_pending_msg->cb(hdev->cmd_pending_msg->cb_context,
skb, err);
else
kfree_skb(skb);

Expand Down
15 changes: 4 additions & 11 deletions net/nfc/hci/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef __LOCAL_HCI_H
#define __LOCAL_HCI_H

#include <net/nfc/hci.h>

struct gate_pipe_map {
u8 gate;
u8 pipe;
Expand All @@ -35,15 +37,6 @@ struct hcp_packet {
struct hcp_message message;
} __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 {
wait_queue_head_t *wq;
bool exec_complete;
Expand All @@ -55,7 +48,7 @@ struct hci_msg {
struct list_head msg_l;
struct sk_buff_head msg_frags;
bool wait_response;
hci_cmd_cb_t cb;
data_exchange_cb_t cb;
void *cb_context;
unsigned long completion_delay;
};
Expand Down Expand Up @@ -83,7 +76,7 @@ struct hci_create_pipe_resp {
int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
u8 type, u8 instruction,
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);

u8 nfc_hci_pipe2gate(struct nfc_hci_dev *hdev, u8 pipe);
Expand Down
4 changes: 2 additions & 2 deletions net/nfc/hci/hcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
u8 type, u8 instruction,
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)
{
struct nfc_dev *ndev = hdev->ndev;
Expand All @@ -52,7 +52,7 @@ int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
skb_queue_head_init(&cmd->msg_frags);
cmd->wait_response = (type == NFC_HCI_HCP_COMMAND) ? true : false;
cmd->cb = cb;
cmd->cb_context = cb_data;
cmd->cb_context = cb_context;
cmd->completion_delay = completion_delay;

hci_len = payload_len + 1;
Expand Down

0 comments on commit b5faa64

Please sign in to comment.