diff options
author | Eric Lapuyade <eric.lapuyade@intel.com> | 2012-05-03 09:35:25 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-07-09 16:42:07 -0400 |
commit | 6c1c5b9e1d8a25268a607c762576b5c16e3e7230 (patch) | |
tree | 83508c5809fed818875d51edf8db083a111b6ec2 /net/nfc | |
parent | 72b06f75fea45fa861f2e137bc94e56aab306c4b (diff) |
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>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/hci/command.c | 18 | ||||
-rw-r--r-- | net/nfc/hci/core.c | 20 | ||||
-rw-r--r-- | net/nfc/hci/hci.h | 7 |
3 files changed, 23 insertions, 22 deletions
diff --git a/net/nfc/hci/command.c b/net/nfc/hci/command.c index 8729abf5f18b..12cd6f3f77ec 100644 --- a/net/nfc/hci/command.c +++ b/net/nfc/hci/command.c | |||
@@ -28,26 +28,14 @@ | |||
28 | 28 | ||
29 | #include "hci.h" | 29 | #include "hci.h" |
30 | 30 | ||
31 | static int nfc_hci_result_to_errno(u8 result) | 31 | static void nfc_hci_execute_cb(struct nfc_hci_dev *hdev, int err, |
32 | { | ||
33 | switch (result) { | ||
34 | case NFC_HCI_ANY_OK: | ||
35 | return 0; | ||
36 | case NFC_HCI_ANY_E_TIMEOUT: | ||
37 | return -ETIMEDOUT; | ||
38 | default: | ||
39 | return -1; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | static void nfc_hci_execute_cb(struct nfc_hci_dev *hdev, u8 result, | ||
44 | struct sk_buff *skb, void *cb_data) | 32 | struct sk_buff *skb, void *cb_data) |
45 | { | 33 | { |
46 | struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)cb_data; | 34 | struct hcp_exec_waiter *hcp_ew = (struct hcp_exec_waiter *)cb_data; |
47 | 35 | ||
48 | pr_debug("HCI Cmd completed with HCI result=%d\n", result); | 36 | pr_debug("HCI Cmd completed with result=%d\n", err); |
49 | 37 | ||
50 | hcp_ew->exec_result = nfc_hci_result_to_errno(result); | 38 | hcp_ew->exec_result = err; |
51 | if (hcp_ew->exec_result == 0) | 39 | if (hcp_ew->exec_result == 0) |
52 | hcp_ew->result_skb = skb; | 40 | hcp_ew->result_skb = skb; |
53 | else | 41 | else |
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index 7d4fdbc06a98..5be7405ce6aa 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -32,6 +32,18 @@ | |||
32 | /* Largest headroom needed for outgoing HCI commands */ | 32 | /* Largest headroom needed for outgoing HCI commands */ |
33 | #define HCI_CMDS_HEADROOM 1 | 33 | #define HCI_CMDS_HEADROOM 1 |
34 | 34 | ||
35 | static int nfc_hci_result_to_errno(u8 result) | ||
36 | { | ||
37 | switch (result) { | ||
38 | case NFC_HCI_ANY_OK: | ||
39 | return 0; | ||
40 | case NFC_HCI_ANY_E_TIMEOUT: | ||
41 | return -ETIME; | ||
42 | default: | ||
43 | return -1; | ||
44 | } | ||
45 | } | ||
46 | |||
35 | static void nfc_hci_msg_tx_work(struct work_struct *work) | 47 | static void nfc_hci_msg_tx_work(struct work_struct *work) |
36 | { | 48 | { |
37 | struct nfc_hci_dev *hdev = container_of(work, struct nfc_hci_dev, | 49 | 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) | |||
46 | if (timer_pending(&hdev->cmd_timer) == 0) { | 58 | if (timer_pending(&hdev->cmd_timer) == 0) { |
47 | if (hdev->cmd_pending_msg->cb) | 59 | if (hdev->cmd_pending_msg->cb) |
48 | hdev->cmd_pending_msg->cb(hdev, | 60 | hdev->cmd_pending_msg->cb(hdev, |
49 | NFC_HCI_ANY_E_TIMEOUT, | 61 | -ETIME, |
50 | NULL, | 62 | NULL, |
51 | hdev-> | 63 | hdev-> |
52 | cmd_pending_msg-> | 64 | cmd_pending_msg-> |
@@ -71,8 +83,7 @@ next_msg: | |||
71 | kfree_skb(skb); | 83 | kfree_skb(skb); |
72 | skb_queue_purge(&msg->msg_frags); | 84 | skb_queue_purge(&msg->msg_frags); |
73 | if (msg->cb) | 85 | if (msg->cb) |
74 | msg->cb(hdev, NFC_HCI_ANY_E_NOK, NULL, | 86 | msg->cb(hdev, r, NULL, msg->cb_context); |
75 | msg->cb_context); | ||
76 | kfree(msg); | 87 | kfree(msg); |
77 | break; | 88 | break; |
78 | } | 89 | } |
@@ -129,7 +140,8 @@ void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result, | |||
129 | del_timer_sync(&hdev->cmd_timer); | 140 | del_timer_sync(&hdev->cmd_timer); |
130 | 141 | ||
131 | if (hdev->cmd_pending_msg->cb) | 142 | if (hdev->cmd_pending_msg->cb) |
132 | hdev->cmd_pending_msg->cb(hdev, result, skb, | 143 | hdev->cmd_pending_msg->cb(hdev, nfc_hci_result_to_errno(result), |
144 | skb, | ||
133 | hdev->cmd_pending_msg->cb_context); | 145 | hdev->cmd_pending_msg->cb_context); |
134 | else | 146 | else |
135 | kfree_skb(skb); | 147 | kfree_skb(skb); |
diff --git a/net/nfc/hci/hci.h b/net/nfc/hci/hci.h index 45f2fe4fd486..d3cde075ba60 100644 --- a/net/nfc/hci/hci.h +++ b/net/nfc/hci/hci.h | |||
@@ -37,10 +37,11 @@ struct hcp_packet { | |||
37 | 37 | ||
38 | /* | 38 | /* |
39 | * HCI command execution completion callback. | 39 | * HCI command execution completion callback. |
40 | * result will be one of the HCI response codes. | 40 | * result will be a standard linux error (may be converted from HCI response) |
41 | * skb contains the response data and must be disposed. | 41 | * skb contains the response data and must be disposed, or may be NULL if |
42 | * an error occured | ||
42 | */ | 43 | */ |
43 | typedef void (*hci_cmd_cb_t) (struct nfc_hci_dev *hdev, u8 result, | 44 | typedef void (*hci_cmd_cb_t) (struct nfc_hci_dev *hdev, int result, |
44 | struct sk_buff *skb, void *cb_data); | 45 | struct sk_buff *skb, void *cb_data); |
45 | 46 | ||
46 | struct hcp_exec_waiter { | 47 | struct hcp_exec_waiter { |