Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccca0d6e authored by Eric Lapuyade's avatar Eric Lapuyade Committed by John W. Linville
Browse files

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: default avatarEric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 456411ca
Loading
Loading
Loading
Loading
+16 −11
Original line number Original line Diff line number Diff line
@@ -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,
static void __nfc_hci_cmd_completion(struct nfc_hci_dev *hdev, int err,
				     struct sk_buff *skb)
				     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);
	del_timer_sync(&hdev->cmd_timer);


	if (hdev->cmd_pending_msg->cb)
	if (hdev->cmd_pending_msg->cb)
		hdev->cmd_pending_msg->cb(hdev, nfc_hci_result_to_errno(result),
		hdev->cmd_pending_msg->cb(hdev, err, skb,
					  skb,
					  hdev->cmd_pending_msg->cb_context);
					  hdev->cmd_pending_msg->cb_context);
	else
	else
		kfree_skb(skb);
		kfree_skb(skb);
@@ -150,6 +142,19 @@ void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result,
	hdev->cmd_pending_msg = NULL;
	hdev->cmd_pending_msg = NULL;


	queue_work(hdev->msg_tx_wq, &hdev->msg_tx_work);
	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:
exit:
	mutex_unlock(&hdev->msg_tx_mutex);
	mutex_unlock(&hdev->msg_tx_mutex);