NFC: Factorize HCI cmd completion
authorEric Lapuyade <eric.lapuyade@intel.com>
Thu, 3 May 2012 13:59:37 +0000 (15:59 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 9 Jul 2012 20:42:08 +0000 (16:42 -0400)
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>
net/nfc/hci/core.c

index 5be7405ce6aae3936bad10a688b2e19d38db5279..9a1a12f8687e57f06b27dff225b3bbd2807dc986 100644 (file)
@@ -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);
This page took 0.027634 seconds and 5 git commands to generate.