summaryrefslogtreecommitdiff
path: root/net/nfc/hci/core.c
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@intel.com>2012-05-03 15:35:25 +0200
committerJohn W. Linville <linville@tuxdriver.com>2012-07-09 16:42:07 -0400
commit6c1c5b9e1d8a25268a607c762576b5c16e3e7230 (patch)
tree83508c5809fed818875d51edf8db083a111b6ec2 /net/nfc/hci/core.c
parent72b06f75fea45fa861f2e137bc94e56aab306c4b (diff)
downloadlinux-3.10-6c1c5b9e1d8a25268a607c762576b5c16e3e7230.tar.gz
linux-3.10-6c1c5b9e1d8a25268a607c762576b5c16e3e7230.tar.bz2
linux-3.10-6c1c5b9e1d8a25268a607c762576b5c16e3e7230.zip
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/hci/core.c')
-rw-r--r--net/nfc/hci/core.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 7d4fdbc06a9..5be7405ce6a 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -32,6 +32,18 @@
/* Largest headroom needed for outgoing HCI commands */
#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)
{
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 (hdev->cmd_pending_msg->cb)
hdev->cmd_pending_msg->cb(hdev,
- NFC_HCI_ANY_E_TIMEOUT,
+ -ETIME,
NULL,
hdev->
cmd_pending_msg->
@@ -71,8 +83,7 @@ next_msg:
kfree_skb(skb);
skb_queue_purge(&msg->msg_frags);
if (msg->cb)
- msg->cb(hdev, NFC_HCI_ANY_E_NOK, NULL,
- msg->cb_context);
+ msg->cb(hdev, r, NULL, msg->cb_context);
kfree(msg);
break;
}
@@ -129,7 +140,8 @@ void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result,
del_timer_sync(&hdev->cmd_timer);
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);
else
kfree_skb(skb);