[PATCH 3/9] ASoc: qcom: q6afe: Use guard() for mutex locks

From: phucduc . bui

Date: Wed Jun 03 2026 - 07:55:27 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.

Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---

NOTE: This patch is compile-tested only.

sound/soc/qcom/qdsp6/q6afe.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c
index 40237267fda0..81a93b6f7e4c 100644
--- a/sound/soc/qcom/qdsp6/q6afe.c
+++ b/sound/soc/qcom/qdsp6/q6afe.c
@@ -1035,7 +1035,7 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
struct aprv2_ibasic_rsp_result_t *result;
int ret;

- mutex_lock(&afe->lock);
+ guard(mutex)(&afe->lock);
if (port) {
wait = &port->wait;
result = &port->result;
@@ -1050,8 +1050,7 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
ret = apr_send_pkt(afe->apr, pkt);
if (ret < 0) {
dev_err(afe->dev, "packet not transmitted (%d)\n", ret);
- ret = -EINVAL;
- goto err;
+ return -EINVAL;
}

ret = wait_event_timeout(*wait, (result->opcode == rsp_opcode),
@@ -1066,9 +1065,6 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct apr_pkt *pkt,
ret = 0;
}

-err:
- mutex_unlock(&afe->lock);
-
return ret;
}

--
2.43.0