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

Commit 8b4d1abf authored by Ashish Jain's avatar Ashish Jain Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: codecs: bg: Fix incorrect propagation of command response



BG codec driver waits for fixed amount of time for a command response
from BG. If the wait times out codec driver moves to send
the next command, if the response for first command is received now
because there are no checks for command specific response, the second
command gets falsely acknowledged. To avoid this, use the token present
in the command response payload to acknowledge response for the appropriate
command.

Change-Id: Idbaf09ae88def0503324d7999c185961b79c215b
Signed-off-by: default avatarAshish Jain <ashishj@codeaurora.org>
parent fc7eae29
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ static int pktzr_resp_cb(void *payload, int size)
	int rc = 0;
	struct pktzr_pkt *pkt;
	struct pktzr_hdr *pkt_hdr;
	struct pktzr_node *pnode, *tmp;

	if (!payload) {
		pr_err("%s: payload is NULL\n", __func__);
@@ -86,11 +87,23 @@ static int pktzr_resp_cb(void *payload, int size)
	pkt = (struct pktzr_pkt *)payload;
	pkt_hdr = &pkt->hdr;

	mutex_lock(&ppriv->pktzr_lock);
	list_for_each_entry_safe(pnode, tmp, &ppriv->ch_list, list) {
		if (pnode->token == pkt_hdr->token) {
			if (pkt_hdr->opcode == PKTZR_BASIC_RESPONSE_RESULT) {
		pr_debug("%s: Command response: success\n", __func__);
				pr_debug("%s: CMD rsp: success token %d\n",
						__func__, pkt_hdr->token);
				complete(&ppriv->thread_complete);
			} else
		pr_err("%s: Command response: fail\n", __func__);
				pr_err("%s: CMD rsp: fail token %d\n",
						__func__, pkt_hdr->token);

			mutex_unlock(&ppriv->pktzr_lock);
			return rc;
		}
	}
	pr_err("Invalid token %d or the command timedOut\n", pkt_hdr->token);
	mutex_unlock(&ppriv->pktzr_lock);
done:
	return rc;
}
@@ -273,12 +286,13 @@ void pktzr_deinit(void)

	if (!ppriv)
		return;

	mutex_lock(&ppriv->pktzr_lock);
	for (i = 0; i < ppriv->num_channels; i++) {
		rc = bg_cdc_channel_close(ppriv->pdev, ppriv->ch_info[i]);
		if (rc)
			pr_err("%s:Failed to close channel\n", __func__);
	}
	mutex_unlock(&ppriv->pktzr_lock);
	reinit_completion(&ppriv->thread_complete);
	mutex_destroy(&ppriv->pktzr_lock);
	kzfree(ppriv);