summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@intel.com>2012-05-03 17:59:37 +0400
committerJohn W. Linville <linville@tuxdriver.com>2012-07-10 00:42:08 +0400
commitccca0d6e8805f12fcda2e740c44afa7191923559 (patch)
treea1aac1d88628098b3a434e42175aad82b04b611d /net
parent456411ca812860d7ba06d3e4013ce1d8b9dbc7cd (diff)
downloadlinux-ccca0d6e8805f12fcda2e740c44afa7191923559.tar.xz
NFC: Factorize HCI cmd completion
HCI cmd can be completed either from an HCI response or from an internal driver or HCI error. This requires to factorize the completion code outside of the device lock. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/nfc/hci/core.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index 5be7405ce6aa..9a1a12f8687e 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -127,21 +127,13 @@ static void nfc_hci_msg_rx_work(struct work_struct *work)
}
}
-void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result,
- struct sk_buff *skb)
+static void __nfc_hci_cmd_completion(struct nfc_hci_dev *hdev, int err,
+ struct sk_buff *skb)
{
- mutex_lock(&hdev->msg_tx_mutex);
-
- if (hdev->cmd_pending_msg == NULL) {
- kfree_skb(skb);
- goto exit;
- }
-
del_timer_sync(&hdev->cmd_timer);
if (hdev->cmd_pending_msg->cb)
- hdev->cmd_pending_msg->cb(hdev, nfc_hci_result_to_errno(result),
- skb,
+ hdev->cmd_pending_msg->cb(hdev, err, skb,
hdev->cmd_pending_msg->cb_context);
else
kfree_skb(skb);
@@ -150,6 +142,19 @@ void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result,
hdev->cmd_pending_msg = NULL;
queue_work(hdev->msg_tx_wq, &hdev->msg_tx_work);
+}
+
+void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result,
+ struct sk_buff *skb)
+{
+ mutex_lock(&hdev->msg_tx_mutex);
+
+ if (hdev->cmd_pending_msg == NULL) {
+ kfree_skb(skb);
+ goto exit;
+ }
+
+ __nfc_hci_cmd_completion(hdev, nfc_hci_result_to_errno(result), skb);
exit:
mutex_unlock(&hdev->msg_tx_mutex);