mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-15 02:05:33 +00:00
NFC: Changed HCI cmd execution completion result to std linux errno
An HCI command can complete either from an HCI response (with an HCI result) or as a consequence of any other system error during processing. The completion therefore needs to take a standard errno code. The HCI response will convert its result to a standard errno before calling the completion. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
72b06f75fe
commit
6c1c5b9e1d
@ -28,26 +28,14 @@
|
|||||||
|
|
||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
|
|
||||||
static int nfc_hci_result_to_errno(u8 result)
|
static void nfc_hci_execute_cb(struct nfc_hci_dev *hdev, int err,
|
||||||
{
|
|
||||||
switch (result) {
|
|
||||||
case NFC_HCI_ANY_OK:
|
|
||||||
return 0;
|
|
||||||
case NFC_HCI_ANY_E_TIMEOUT:
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nfc_hci_execute_cb(struct nfc_hci_dev *hdev, u8 result,
|
|
||||||
struct sk_buff *skb, void *cb_data)
|
struct sk_buff *skb, void *cb_data)
|
||||||
{
|
{
|
||||||
struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)cb_data;
|
struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)cb_data;
|
||||||
|
|
||||||
pr_debug("HCI Cmd completed with HCI result=%d\n", result);
|
pr_debug("HCI Cmd completed with result=%d\n", err);
|
||||||
|
|
||||||
hcp_ew->exec_result = nfc_hci_result_to_errno(result);
|
hcp_ew->exec_result = err;
|
||||||
if (hcp_ew->exec_result == 0)
|
if (hcp_ew->exec_result == 0)
|
||||||
hcp_ew->result_skb = skb;
|
hcp_ew->result_skb = skb;
|
||||||
else
|
else
|
||||||
|
@ -32,6 +32,18 @@
|
|||||||
/* Largest headroom needed for outgoing HCI commands */
|
/* Largest headroom needed for outgoing HCI commands */
|
||||||
#define HCI_CMDS_HEADROOM 1
|
#define HCI_CMDS_HEADROOM 1
|
||||||
|
|
||||||
|
static int nfc_hci_result_to_errno(u8 result)
|
||||||
|
{
|
||||||
|
switch (result) {
|
||||||
|
case NFC_HCI_ANY_OK:
|
||||||
|
return 0;
|
||||||
|
case NFC_HCI_ANY_E_TIMEOUT:
|
||||||
|
return -ETIME;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void nfc_hci_msg_tx_work(struct work_struct *work)
|
static void nfc_hci_msg_tx_work(struct work_struct *work)
|
||||||
{
|
{
|
||||||
struct nfc_hci_dev *hdev = container_of(work, struct nfc_hci_dev,
|
struct nfc_hci_dev *hdev = container_of(work, struct nfc_hci_dev,
|
||||||
@ -46,7 +58,7 @@ static void nfc_hci_msg_tx_work(struct work_struct *work)
|
|||||||
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,
|
||||||
NFC_HCI_ANY_E_TIMEOUT,
|
-ETIME,
|
||||||
NULL,
|
NULL,
|
||||||
hdev->
|
hdev->
|
||||||
cmd_pending_msg->
|
cmd_pending_msg->
|
||||||
@ -71,8 +83,7 @@ next_msg:
|
|||||||
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, NFC_HCI_ANY_E_NOK, NULL,
|
msg->cb(hdev, r, NULL, msg->cb_context);
|
||||||
msg->cb_context);
|
|
||||||
kfree(msg);
|
kfree(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -129,7 +140,8 @@ void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result,
|
|||||||
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, result, skb,
|
hdev->cmd_pending_msg->cb(hdev, nfc_hci_result_to_errno(result),
|
||||||
|
skb,
|
||||||
hdev->cmd_pending_msg->cb_context);
|
hdev->cmd_pending_msg->cb_context);
|
||||||
else
|
else
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
|
@ -37,10 +37,11 @@ struct hcp_packet {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* HCI command execution completion callback.
|
* HCI command execution completion callback.
|
||||||
* result will be one of the HCI response codes.
|
* result will be a standard linux error (may be converted from HCI response)
|
||||||
* skb contains the response data and must be disposed.
|
* 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, u8 result,
|
typedef void (*hci_cmd_cb_t) (struct nfc_hci_dev *hdev, int result,
|
||||||
struct sk_buff *skb, void *cb_data);
|
struct sk_buff *skb, void *cb_data);
|
||||||
|
|
||||||
struct hcp_exec_waiter {
|
struct hcp_exec_waiter {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user