From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B751F3A4512 for ; Wed, 3 Jun 2026 11:50:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487415; cv=none; b=dw11tgohU+8748IevvRh/mkt6ciMdNPij0y7+phJoZhond8TpF92byRmH0nsxp5fArOia0oJ6X1ygh4vhlDntArMPoaRT4aLqosiDgzZFyldQ30pieHMFMwrGl2yW5NEbTtl6KImv3bQFXHAXvnHL5jZoVaRG4lLMGKIYulr4e0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487415; c=relaxed/simple; bh=9geJzNgf+WThNkg/OcdRMOvKScGM8OBuCVL+aiam9IE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VnbCqgczDW+3gUtUPZMczBPQLrIppCEDfau3LDtioGk4DngqdxQM5DixkH1xAuxE+bnguGfDW8IlBHB4pgTQDYJfJjd9ok+hXC+ACkvx15/0V0ID/pR9MoH124yQxS2MMNSodWy38d6OMYHcf9TzD8RsqPXcfbhdFqI5Obh9pEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bRx9x5wz; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bRx9x5wz" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2bf30d530bdso51858415ad.3 for ; Wed, 03 Jun 2026 04:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487414; x=1781092214; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4pqU/kQ2HBq/qGDKu6bV8BUK3iXPtSyo8YwmhrKH15Y=; b=bRx9x5wzr5SVaeGqC02tnz3gOVViL4iKUMO6Qf10T5p8CA7XIx4vn84s8fCRS9qMCu UTGyWjnGate6VI9QrRqzZlHC2o+bFFdiYiSgN8Y+IlOcTcXHAX6YdLlGyb2gdCgqRlmQ 6HD3WbyNhJO9tPMcADWWTL3Q0QYCkLsnrhJiC+c29hnAqv0GmQHVP8D5aJJzPi0Rhfq5 cQ3rHpujGvlhQVeV05qnZYyPLZ75XjeA/uAW2bW/mKTN/Ec0fRFsgivJe3jBsCM6Gcw4 in4zVQelXx7TvZ0Np8g/ugl7wblRJvlNC1QKm0SWVbCKFCpa+bSFmMgh6ZUx/qikK3BG lQhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487414; x=1781092214; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4pqU/kQ2HBq/qGDKu6bV8BUK3iXPtSyo8YwmhrKH15Y=; b=GIt2sFh5Oq2QKAhLCkUWQzvVt2GK1G5W6AHA1OlfAOknmrVwcPWHuKsDufew+rQ7ce lDN2SBsuZgbkZ8azmcWxDN8myd0PHZhnMlwpRQYaUcMvphdUJSELHXa3foFMcLu8/nno Ol4VMVbN4Qn9bHfwrCQrgOtg5uA+2h8FXTwwo49m/ZTqzRa4aBovIbrp7wZlhvIyD5Xh Wjg9JiJn9k/YRrjkfbdMi7ojW24ot1mg22kg0VrksSoqdnw5uxjPa3A5UFn99Iw3BURT 1FsRIRm5O1ZJYN4PK0qsDVavSyR41Krix1Qyli4NjUrzGcCQ0dvap6MTdMeZgtvLkbNp HsXw== X-Forwarded-Encrypted: i=1; AFNElJ/6jMNBE8uafuo+TWY2m7JkuW9K7rta0kOLE40Q7h1HneU65UaKH/Q6NXEh8bP+rVLORNYc6TuYYpO4yWY=@vger.kernel.org X-Gm-Message-State: AOJu0YzEhCghAbeoHshjrkPm/MgSsDdX612r+lVKdCD/ZyxGTNY0hVi7 2uWQ6Nw36gabHSj/7ehYe8chd95dnlNjuR+2YPwrXY0wkg5XgXjzfbpK X-Gm-Gg: Acq92OGDqY8lDok+51y/+ed0qyALuraNkNdooTt/eFrBnHT2qBTumiiYMsq0uAjY6sU vU1QZrpdoLe9n6/MrugDX5UdujkRasLDjn6t0asYmyUnbjPFzF+ZHXtZwz2hTtljH7xT/8KsiDt sCUKsFR+ocSoRnx4azzvV2SokYd5mmvHI1a3fTp1ZssbYT1QvQqaUSoJSgGyR17AJmMG7aJ58Xu b8YTcEZpa9vM9SRGjCLG5MbTm3rBnwl0Kqj+IFW3uIRsYDj7ZIuskQxyIiV7FbN9QOPWe8T7V1m KHa3CvWPfbyX8TZbcv6XAVX8pnwrXhGXHlrYEblO1F8wCbenjXCCGqpU7ucjg43HXRk7bPjGGi0 vJ0uypwt9DMBRJpBLfadVYfRAMg/jH1g8PCbBodYArCzQClXWWMKOfh5Wci0JH4bY+tCoAHWFlp GBq3naQAWlozqEj5SGdPQ2iADPvtk41YV7VaKaaWXjwPgOXboyx3oK5XM3GwAeEMRf82PF X-Received: by 2002:a17:903:298c:b0:2c1:4d9:c8db with SMTP id d9443c01a7336-2c1644dbfbamr33614925ad.37.1780487414015; Wed, 03 Jun 2026 04:50:14 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:13 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 1/9] ASoC: qcom: audioreach: Use guard() for mutex locks Date: Wed, 3 Jun 2026 18:49:41 +0700 Message-ID: <20260603114949.149595-2-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- NOTE: This patch is compile-tested only. sound/soc/qcom/qdsp6/audioreach.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audio= reach.c index a13f753eff98..8b3d1410c788 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -585,7 +585,7 @@ int audioreach_send_cmd_sync(struct device *dev, gpr_de= vice_t *gdev, const struct gpr_hdr *hdr =3D &pkt->hdr; int rc; =20 - mutex_lock(cmd_lock); + guard(mutex)(cmd_lock); result->opcode =3D 0; result->status =3D 0; =20 @@ -597,7 +597,7 @@ int audioreach_send_cmd_sync(struct device *dev, gpr_de= vice_t *gdev, rc =3D -EINVAL; =20 if (rc < 0) - goto err; + return rc; =20 if (rsp_opcode) rc =3D wait_event_timeout(*cmd_wait, (result->opcode =3D=3D hdr->opcode)= || @@ -616,8 +616,6 @@ int audioreach_send_cmd_sync(struct device *dev, gpr_de= vice_t *gdev, rc =3D 0; } =20 -err: - mutex_unlock(cmd_lock); return rc; } EXPORT_SYMBOL_GPL(audioreach_send_cmd_sync); @@ -1387,7 +1385,7 @@ void audioreach_graph_free_buf(struct q6apm_graph *gr= aph) { struct audioreach_graph_data *port; =20 - mutex_lock(&graph->lock); + guard(mutex)(&graph->lock); port =3D &graph->rx_data; port->num_periods =3D 0; kfree(port->buf); @@ -1397,7 +1395,6 @@ void audioreach_graph_free_buf(struct q6apm_graph *gr= aph) port->num_periods =3D 0; kfree(port->buf); port->buf =3D NULL; - mutex_unlock(&graph->lock); } EXPORT_SYMBOL_GPL(audioreach_graph_free_buf); =20 --=20 2.43.0 From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B650830567B for ; Wed, 3 Jun 2026 11:50:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487422; cv=none; b=Ox9NUIsPUJQ9ATdI9h6w6A9iwrgJggKTN9CDmDg+UPgxCwFwTy2hpuk+6y/TP8uj3R0h69sEkubhWwqGmPSCONMD32G1DeT+Zn3cv9KUdzH2Roj1AHmf2znSinrsywxejxlhen+QLH6NMpswcXnLfJe/+gIp9BfoPFoPwdxJU6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487422; c=relaxed/simple; bh=uwV6PO5DlFDznk+uJv/Pq9Nwi/vMbNemlLYmv9EURcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PkCuIeZWOJT3ldJAD38li5LmUOqAmUMuO6WNyKSxevDdoR7u6E0uXG1uRX/86pHXe3P3HZD6TCM7r4/wVHIm+v6V/geTRSjtykFuboR2HxDUito5yrxVimPIWIiApiJtehMAJYq3rFFEkF+7cPUzSSeE6XGAYbG9aXAiwAEVdpY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NSQSBq5O; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NSQSBq5O" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2c0c1e0b0faso25400655ad.0 for ; Wed, 03 Jun 2026 04:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487420; x=1781092220; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ihPu9yJ7cbZM2Z9enb1eM3sg+iZi8+aG7UspBvf/VzQ=; b=NSQSBq5OXVbkWTbEEbBC5mSfCx8Z4f3jBsj/yYBmEtGmIDY2GOdjulDkdBDy/AU0tj BYiQHnw5JdFwNa+Eb8TJz1gv/uxMqyO/OY6CdSRLdXxdsYo1nkgA5qjZQimyKwKyMu38 EkWCRyusjMVJrYXEI0niA5rkDYbXbCEP52Xz6GW4oIpk0GGBEVW4razDARgmYskabDWr qWr7b+eC6IK8W8uHZ55rUWfSblSQSkwJ941w9YvVfvP6gjW35XvmNSQNVW68t82woTEd MNIfa/5SOfsf//C621I/M43qfs0yRK4ok/GUr4CMC+HtJ2n+vU4JvH/b8Hh42oa2sSgS pFsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487420; x=1781092220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ihPu9yJ7cbZM2Z9enb1eM3sg+iZi8+aG7UspBvf/VzQ=; b=UKo17BJCj4F/Pu2HT2WEoEHkRAF1+Je3GUHSwHB5hdgzPhbF5ShkZT62PJFqej1KB+ TamSceLG1C7JJ92oQwsYW8A3gg2RiWAu6QvSWM3jjlXtFSVWjwdL9chGRL2jU1VSkuwk 3/2CE1Ua7j4iNt2elr0l6Hup21JOKWpyWVqzECqS9jXmfWOyn2LURR9A+1+DvwjRlF1R Xpj3optijxruWo0moEj6LbQ7JGJdB50c14KZFwmsDeMeezd4VAe24xcnlbR7EujqOj/E fgqOyQKq/YMIfg/dWQaiHrha6vJ8ZWVvee5ZKN2J6saySXeTY7IyptTsr6Qd71yJVd0h UE2w== X-Forwarded-Encrypted: i=1; AFNElJ8MJrEUPIKCJY61Z1LjADS9sazygYoBa3bX73y271cHQaNrv8QbwedhQKpL6DwhH+hLazvWmMw1qOCMsTY=@vger.kernel.org X-Gm-Message-State: AOJu0YzFGmRtgCLjevBCc5SRIZCoa54VVwFEYz57rRjjUKpHtNTn8eLH +65mEHtG81hs3Rs2/woZfYdeYiEMtTHAefGQs1tVa8jWC3Us+1pFM2zB X-Gm-Gg: Acq92OGrkj5pp0MynOE2Ut8AtbnHDvpy/sMVZ4iN+oANuAbz7aBafBCK6Ih7LJ01Rs+ 2RgePs1UclbW7rQ0bAkrW2U1hRhBKg2hE5ZreIipniG871JRhRpeXzjGF6doLWqZU2NtT5Qgjn8 mZduEIlqB8Q1eHrE8qiC71C0qzM/ukQpcoC5pV/Ety8NulIMMim39k61W03D/SYUIhzF60+zI6C nTBDnrTOcDRDVzQgftjLCFaNeW3TqhwuqRtF3Jzx8+t4wrdyNSjOmz7sg6KBRkQcm6xApVLUVKD gx8OaWrQE3glTNFlvR71TPPPDVxUw+aXzxmUc/nj6q6m/P0ClDgw5cvKuB3Ha6NPX7YC5WOIZNo d2xiENJRtdpkToM1b+lSzvebibGeUfHZ58bhgE2+NWPsDPZuCZIR/JKrvOX1NwRisV6l2bPtAdQ VbVUyr0AgIAS7LnrD6VT4skL2mykN6BDtPXKd3bI6YGsq6Rt4ZTtDiJ2qc2/acS0A6AstF X-Received: by 2002:a17:902:f706:b0:2c1:5667:2740 with SMTP id d9443c01a7336-2c163fad884mr31227115ad.21.1780487419974; Wed, 03 Jun 2026 04:50:19 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:19 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 2/9] ASoc: qcom: q6adm: Use guard() for mutex & spin locks Date: Wed, 3 Jun 2026 18:49:42 +0700 Message-ID: <20260603114949.149595-3-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex & spin locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- NOTE: This patch is compile-tested only. sound/soc/qcom/qdsp6/q6adm.c | 52 +++++++++++++----------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6adm.c b/sound/soc/qcom/qdsp6/q6adm.c index db0ae71f2983..44c268c3e529 100644 --- a/sound/soc/qcom/qdsp6/q6adm.c +++ b/sound/soc/qcom/qdsp6/q6adm.c @@ -92,9 +92,8 @@ static struct q6copp *q6adm_find_copp(struct q6adm *adm, = int port_idx, { struct q6copp *c; struct q6copp *ret =3D NULL; - unsigned long flags; =20 - spin_lock_irqsave(&adm->copps_list_lock, flags); + guard(spinlock_irqsave)(&adm->copps_list_lock); list_for_each_entry(c, &adm->copps_list, node) { if ((port_idx =3D=3D c->afe_port) && (copp_idx =3D=3D c->copp_idx)) { ret =3D c; @@ -103,8 +102,6 @@ static struct q6copp *q6adm_find_copp(struct q6adm *adm= , int port_idx, } } =20 - spin_unlock_irqrestore(&adm->copps_list_lock, flags); - return ret; =20 } @@ -116,14 +113,13 @@ static int q6adm_apr_send_copp_pkt(struct q6adm *adm,= struct q6copp *copp, uint32_t opcode =3D pkt->hdr.opcode; int ret; =20 - mutex_lock(&adm->lock); + guard(mutex)(&adm->lock); copp->result.opcode =3D 0; copp->result.status =3D 0; ret =3D apr_send_pkt(adm->apr, pkt); if (ret < 0) { dev_err(dev, "Failed to send APR packet\n"); - ret =3D -EINVAL; - goto err; + return -EINVAL; } =20 /* Wait for the callback with copp id */ @@ -146,8 +142,6 @@ static int q6adm_apr_send_copp_pkt(struct q6adm *adm, s= truct q6copp *copp, ret =3D -EINVAL; } =20 -err: - mutex_unlock(&adm->lock); return ret; } =20 @@ -172,17 +166,16 @@ static void q6adm_free_copp(struct kref *ref) { struct q6copp *c =3D container_of(ref, struct q6copp, refcount); struct q6adm *adm =3D c->adm; - unsigned long flags; int ret; =20 ret =3D q6adm_device_close(adm, c, c->afe_port, c->copp_idx); if (ret < 0) dev_err(adm->dev, "Failed to close copp %d\n", ret); =20 - spin_lock_irqsave(&adm->copps_list_lock, flags); - clear_bit(c->copp_idx, &adm->copp_bitmap[c->afe_port]); - list_del(&c->node); - spin_unlock_irqrestore(&adm->copps_list_lock, flags); + scoped_guard(spinlock_irqsave, &adm->copps_list_lock) { + clear_bit(c->copp_idx, &adm->copp_bitmap[c->afe_port]); + list_del(&c->node); + } kfree(c); } =20 @@ -306,9 +299,8 @@ static struct q6copp *q6adm_find_matching_copp(struct q= 6adm *adm, { struct q6copp *c; struct q6copp *ret =3D NULL; - unsigned long flags; =20 - spin_lock_irqsave(&adm->copps_list_lock, flags); + guard(spinlock_irqsave)(&adm->copps_list_lock); =20 list_for_each_entry(c, &adm->copps_list, node) { if ((port_id =3D=3D c->afe_port) && (topology =3D=3D c->topology) && @@ -318,7 +310,6 @@ static struct q6copp *q6adm_find_matching_copp(struct q= 6adm *adm, kref_get(&c->refcount); } } - spin_unlock_irqrestore(&adm->copps_list_lock, flags); =20 return ret; } @@ -384,7 +375,6 @@ struct q6copp *q6adm_open(struct device *dev, int port_= id, int path, int rate, { struct q6adm *adm =3D dev_get_drvdata(dev->parent); struct q6copp *copp; - unsigned long flags; int ret =3D 0; =20 if (port_id < 0) { @@ -399,15 +389,13 @@ struct q6copp *q6adm_open(struct device *dev, int por= t_id, int path, int rate, return copp; } =20 - spin_lock_irqsave(&adm->copps_list_lock, flags); - copp =3D q6adm_alloc_copp(adm, port_id); - if (IS_ERR(copp)) { - spin_unlock_irqrestore(&adm->copps_list_lock, flags); - return ERR_CAST(copp); - } + scoped_guard(spinlock_irqsave, &adm->copps_list_lock) { + copp =3D q6adm_alloc_copp(adm, port_id); + if (IS_ERR(copp)) + return ERR_CAST(copp); =20 - list_add_tail(&copp->node, &adm->copps_list); - spin_unlock_irqrestore(&adm->copps_list_lock, flags); + list_add_tail(&copp->node, &adm->copps_list); + } =20 kref_init(&copp->refcount); copp->topology =3D topology; @@ -518,7 +506,7 @@ int q6adm_matrix_map(struct device *dev, int path, kref_put(&copp->refcount, q6adm_free_copp); } =20 - mutex_lock(&adm->lock); + guard(mutex)(&adm->lock); adm->result.status =3D 0; adm->result.opcode =3D 0; =20 @@ -526,7 +514,7 @@ int q6adm_matrix_map(struct device *dev, int path, if (ret < 0) { dev_err(dev, "routing for stream %d failed ret %d\n", payload_map.session_id, ret); - goto fail_cmd; + return ret; } ret =3D wait_event_timeout(adm->matrix_map_wait, adm->result.opcode =3D=3D pkt->hdr.opcode, @@ -534,17 +522,13 @@ int q6adm_matrix_map(struct device *dev, int path, if (!ret) { dev_err(dev, "routing for stream %d failed\n", payload_map.session_id); - ret =3D -ETIMEDOUT; - goto fail_cmd; + return -ETIMEDOUT; } else if (adm->result.status > 0) { dev_err(dev, "DSP returned error[%d]\n", adm->result.status); - ret =3D -EINVAL; - goto fail_cmd; + return -EINVAL; } =20 -fail_cmd: - mutex_unlock(&adm->lock); return ret; } EXPORT_SYMBOL_GPL(q6adm_matrix_map); --=20 2.43.0 From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFF06472786 for ; Wed, 3 Jun 2026 11:50:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487426; cv=none; b=J3o32sCCpIUWu2iFZ39f6Z9jjp/Cajp0LckxQdWRjeuiuNPXyRqV+krsFtx+rRxGihT7TD67KGE1INI7Hy6kaTxyNmqeawYGlcGrROq9gZPXa2j9l1UpDsLnMSclp/gcS/Y8WJr8JB07Gx0rslvkQL0X2qcO++/OyAxcG0hUzRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487426; c=relaxed/simple; bh=iRqMG9DN/p0d7WwrGgFPpJSCy0qf0D8Q2xI7Rv5LrNY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WpsX9nCHytxEZ6rd2pe0Tj/mvsgEdIWHB701BF58yFxoGEWgJCjg+h5n2QaOu8N1go8u3h+/A5crp/OexiMSnGkjdd26TBr0VCkwBITgc8zQo5aoBDQE3wBx4K1RzKD3fc4fc0u2rs6XXK/mMQQ6k6/eYWotH3T5Nu9CeKisn+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZyJXfKWt; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZyJXfKWt" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2c0c2c7d45eso33859485ad.1 for ; Wed, 03 Jun 2026 04:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487424; x=1781092224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zsEQCBEsoTa7MTlBM/uxhWN3Fk4N0THbIr2xqO/n6O0=; b=ZyJXfKWtBp2WSReas1Z8Nunop+OgkCNxXlO5eBvjJgIjNHwKJMqAyMc2ykSaIlxAX+ ehQph48+Cxyc45kO9GWblw76vWHfAw+w5ayAz+i7EfUYxhynVC3rEwh6v08M2M5aXWnV Pjffx1T7gl/ea41nTZ1yTcokJTvKopxScF6zNygsdTGjfELkH3gvY18TFu5cQxzBNU72 nVfcm5LFHZAM2cYo7eTRuOsSNr8uhL9P2iRSzIBhDQn0LqktPRAFr8tDJ+lTjArkFrgl wfiN4B+ZvTXQw1RTR1FcS3tq76KQx1WzR9ABx1HkWOf+PUdDViSWN2+pIZ0V7gTCcVpo 3pVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487424; x=1781092224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zsEQCBEsoTa7MTlBM/uxhWN3Fk4N0THbIr2xqO/n6O0=; b=iVkuBBKWkfyh6FW30KuX1PgxrboQI0gfKfFns+xbXNddRzgqdH7gp5Uh5ePuG1PQhw x/RFkf1dOG+ufVXLk49Mf853CCFZbb+keEXAx76K+BVQa+SR504Cw01nHvAV6xNn2nZ8 sjrBtasyhzEmH9A38oUvNFVz8FiASrlrkevTy/DZsxK2A2ywC6wFlff2QEj2DlUw/tO7 uktYaTC53k3PIDxNguThopGvUeFzGyBUltqVs8bs21LTHX+b+ngbQZzlEDCSgQKxzstM 0y2WiJeUPlF3BG/WMHOo4DaQTvJsqFLMRaNG/JDUIOq4Y1ynFUiIU7ISI3tsNainJkZd +vQw== X-Forwarded-Encrypted: i=1; AFNElJ/mkbzCjntx8LTQW5TwHdcqgxubshqPm9tFMblQefootXqveg4hcnAlDEmG6ZyX0snQOHcJ3uc4PhPjLi0=@vger.kernel.org X-Gm-Message-State: AOJu0YxdHsEm7ZsofDf4ddLYtNRpMMCJqNipKbnjNCF/14+NdGaAwqbH kBFgVvqztU1boTc1+7bGxFaL2y2p/oBoJKhMvamLiuXNWL3cZ5i97RtL X-Gm-Gg: Acq92OFVVonvRoHvXOIt+JoU1hlf1Q7/ux3hE6cGlAPWKKmrJORakEpFoOwv5lSqsu2 /vkEteezm+HwOtQpHvMYFg8pHiEwtdaIR832s/DLprp4eLd6SLzUbh4wjVOTgXcwPRLi/k9MNhx Xl1XDYRkzXE+e/TnTUCNpaLdDEQawXXw+vDuffJvJ0GCd9thqglS65jkUdqxrbKx7qqMFnXSoOr +VVODcZ6KSUoFv1kza1PKX612Jh1A1QRjyvZqLlUYTn2+rjKxz5IgAufR3wucJ7YKT4HPgLeSmS /ev+qaXugzbPFzgqLDNF2p4+KfbPn/KnMkocekxYJRmdiVmyAj9KyXuT3ESUFbuFjucx+GCcxpK p5sg4S33C76KeijbdbL3tX/zoIfaggxD2kdCzGEVF9fm9PvVRwtjQpMvP2S2Ou1x4YrfxEt2n32 DXEQUKDg81xs4WY0WRThOCngOziYRflXXSdHx5+6FTdsbDFSjKGLVX1uQq/iXNkveabNJL X-Received: by 2002:a17:903:2b03:b0:2c0:b319:fb43 with SMTP id d9443c01a7336-2c163d92b07mr31337955ad.21.1780487423940; Wed, 03 Jun 2026 04:50:23 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:23 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 3/9] ASoc: qcom: q6afe: Use guard() for mutex locks Date: Wed, 3 Jun 2026 18:49:43 +0700 Message-ID: <20260603114949.149595-4-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- 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; =20 - mutex_lock(&afe->lock); + guard(mutex)(&afe->lock); if (port) { wait =3D &port->wait; result =3D &port->result; @@ -1050,8 +1050,7 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct= apr_pkt *pkt, ret =3D apr_send_pkt(afe->apr, pkt); if (ret < 0) { dev_err(afe->dev, "packet not transmitted (%d)\n", ret); - ret =3D -EINVAL; - goto err; + return -EINVAL; } =20 ret =3D wait_event_timeout(*wait, (result->opcode =3D=3D rsp_opcode), @@ -1066,9 +1065,6 @@ static int afe_apr_send_pkt(struct q6afe *afe, struct= apr_pkt *pkt, ret =3D 0; } =20 -err: - mutex_unlock(&afe->lock); - return ret; } =20 --=20 2.43.0 From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 735A147278F for ; Wed, 3 Jun 2026 11:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487429; cv=none; b=rbuk7nkzpevAK1yuWnvK6CFVA5eGhwfoFXTGrp4YTqElCyJ6ajUtivpx+QU0iRqcs7UjvQDpBGKjNuv/nsdGsHXTAntwZU7xA6GrluireT9lI+dhwCKzWq3IQb5xW807f15Cv40z5vz/HKeeSjcQM2j1c4GA3YHEQbEoz3fgIPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487429; c=relaxed/simple; bh=he35cP/gvA5xSZMWrFOaF04BmRJcyzkN8tKIS3U8k/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nLH62+bxppZMjgY5cJnfiILBegH4Ri/CAU+dOwJkgYXxg1lKYrzqAivgCCiW7uHHc3QKjfxSDVCsAog+/l7rtFmwgmLdiobz1e81OvtR5Sp6YrKH14wy/pk8iHZ6EL6L6Mr06GiqpFYmcK6fAsk6WWQ1TP0/k4vamZiquM5ZKg0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lcui2KWM; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lcui2KWM" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-36c68964315so2474835a91.2 for ; Wed, 03 Jun 2026 04:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487428; x=1781092228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7cxTSMgNqZwdOR4PrDlBQXp8DTW1iK+QB/aZTwgHd9A=; b=lcui2KWM+W7k3FGtUD2BlL15BckvNeHwmrakJQ9XApwJx+Bew0FSNpyLkU6FArwJlQ GQ6E98UyCyzRv9+dDIDY9PKZZewc/yqiFvOHlk3+5Nm5GlxCXzzL7EYU75vsRu1ceTFM oceD8kZgutOUncKSzL1BAfVTCFVLfzvjrg4RMitJeC7G+tMefI/MFV4tpLvuZ2iWmAhw WxZxz+TG3+50fl7dxdZcXrV+4MWZ2vMU89mat4WKyWphZkKdLRIn9rrlZIsaJadDPsTz opnpXh/YMACuSb3610PI9a0ok48wr/RO0K2Vtke0auk2GOLPY7VYFztJex97BH8K6082 O1Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487428; x=1781092228; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7cxTSMgNqZwdOR4PrDlBQXp8DTW1iK+QB/aZTwgHd9A=; b=CWhD026Aic1LziReXsJjwa6A3rLXPKyXfCcjzomfeQahbXWpBgf6bToMZrwveE02Jx rLuaSPwNqIpiYEuCy71EqJRsRug8MHfsmDXIxfzKoDe0axpMNpv4hfCieOlSXD6DxLNe QOfhYBF9+OhYab1xP9+Ryv80iAcqVvQvw3ty0bw2aGqn3SVdyKXiy1cgWV/TlTj1DvGW 1sTLgfIOfPNRVdDxSN3bY+1mPMPYU16OdX6Dtu0Sxkpe6Y8vx5XyngQkB6xyd+iLvne1 nZtb7SFklHVYVkhOWeiDpsFfsD6utY15ZQ9WcDJiysGac/ZWSDVfm1bdv8CTPXTp05sE uwJQ== X-Forwarded-Encrypted: i=1; AFNElJ/gIdc/WfshQwiHcxJtJSHzKK8BFKxx7JYQZYrRVI2G81cQCwg4KjGp3ZZocbYNtKu2sWIgkuVVwyTqgNY=@vger.kernel.org X-Gm-Message-State: AOJu0YyS+LXrrIDU5MfrJ4M50naebaWZVCz+vO0GxTY4aMkpe3kCRjzA 0yyJk6m3FzR8RosvFWWNFFkDD8w2HmyExqjRfBFFJ3qDu8H4w03SZ5HB X-Gm-Gg: Acq92OE4cL2SN6hX75jo1FsPnOsmjo0g390gVUx9SUC+bwHXyGcMYeWspTcebsE7Gc7 QlxFmHejO7qZD/bsJpAMWPYL3xfImC8KnZ7a6h1UOTjQT+rf0JUn4tr5QCQt3uydmWfDnwPcIcw jnCYUuATUTaRtZ+GQR66zsEcV+hw8WeJHfyI8OEX9LRfQvIL9lmhLE1pq/RtQAfXfh8uIc78h7+ cjGDOLzWBHrqOYUYECjkIgp1DKvmS9sP3CkmpNBw6gi/y2IpP1GMZ+hNAjzE1rqRaDXzxIOMXHe 9+X3NmBwD+AhaWZlXKGbwQCGthA/tD6mjoEdaKOFnLeXO+l7SxpVFhhxbGnyFfb5FGaSQbj8J7/ m4pwN6Pij3Q5xRasSEX5KdVPq5HQR6fyS7sS3F1p9r0e3z4LeMc86T9C5/4izXE7RoP6Zk2zZdo BOpFFHZeEumYgydoHEGNeoHM5Ssb6R2gfEgdIS9PtkfjNBUwKhFXtXIGN3KKxKviVe7XqX X-Received: by 2002:a17:902:e14c:b0:2b9:ec37:2977 with SMTP id d9443c01a7336-2c1644dbfd2mr18979195ad.38.1780487427507; Wed, 03 Jun 2026 04:50:27 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:27 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 4/9] ASoC: qcom: q6apm: Use guard() for mutex locks Date: Wed, 3 Jun 2026 18:49:44 +0700 Message-ID: <20260603114949.149595-5-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- NOTE: This patch is compile-tested only. sound/soc/qcom/qdsp6/q6apm.c | 107 ++++++++++++++++------------------- 1 file changed, 48 insertions(+), 59 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 2ab378fb5032..17c44587b084 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -44,9 +44,8 @@ static struct audioreach_graph *q6apm_get_audioreach_grap= h(struct q6apm *apm, ui struct audioreach_graph *graph; int id; =20 - mutex_lock(&apm->lock); - graph =3D idr_find(&apm->graph_idr, graph_id); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + graph =3D idr_find(&apm->graph_idr, graph_id); =20 if (graph) { kref_get(&graph->refcount); @@ -74,16 +73,15 @@ static struct audioreach_graph *q6apm_get_audioreach_gr= aph(struct q6apm *apm, ui return ERR_CAST(err); } =20 - mutex_lock(&apm->lock); - id =3D idr_alloc(&apm->graph_idr, graph, graph_id, graph_id + 1, GFP_KERN= EL); - if (id < 0) { - dev_err(apm->dev, "Unable to allocate graph id (%d)\n", graph_id); - kfree(graph->graph); - kfree(graph); - mutex_unlock(&apm->lock); - return ERR_PTR(id); + scoped_guard(mutex, &apm->lock) { + id =3D idr_alloc(&apm->graph_idr, graph, graph_id, graph_id + 1, GFP_KER= NEL); + if (id < 0) { + dev_err(apm->dev, "Unable to allocate graph id (%d)\n", graph_id); + kfree(graph->graph); + kfree(graph); + return ERR_PTR(id); + } } - mutex_unlock(&apm->lock); =20 kref_init(&graph->refcount); =20 @@ -131,9 +129,8 @@ static void q6apm_put_audioreach_graph(struct kref *ref) =20 audioreach_graph_mgmt_cmd(graph, APM_CMD_GRAPH_CLOSE); =20 - mutex_lock(&apm->lock); - graph =3D idr_remove(&apm->graph_idr, graph->id); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + graph =3D idr_remove(&apm->graph_idr, graph->id); =20 kfree(graph->graph); kfree(graph); @@ -254,20 +251,16 @@ int q6apm_alloc_fragments(struct q6apm_graph *graph, = unsigned int dir, phys_addr else data =3D &graph->tx_data; =20 - mutex_lock(&graph->lock); + guard(mutex)(&graph->lock); =20 data->dsp_buf =3D 0; =20 - if (data->buf) { - mutex_unlock(&graph->lock); + if (data->buf) return 0; - } =20 buf =3D kzalloc_objs(struct audio_buffer, periods); - if (!buf) { - mutex_unlock(&graph->lock); + if (!buf) return -ENOMEM; - } =20 if (dir =3D=3D SNDRV_PCM_STREAM_PLAYBACK) data =3D &graph->rx_data; @@ -287,8 +280,6 @@ int q6apm_alloc_fragments(struct q6apm_graph *graph, un= signed int dir, phys_addr } data->num_periods =3D periods; =20 - mutex_unlock(&graph->lock); - return 0; } EXPORT_SYMBOL_GPL(q6apm_alloc_fragments); @@ -457,23 +448,22 @@ int q6apm_write_async(struct q6apm_graph *graph, uint= 32_t len, uint32_t msw_ts, =20 write_buffer =3D (void *)pkt + GPR_HDR_SIZE; =20 - mutex_lock(&graph->lock); - ab =3D &graph->rx_data.buf[graph->rx_data.dsp_buf]; - - write_buffer->buf_addr_lsw =3D lower_32_bits(ab->phys); - write_buffer->buf_addr_msw =3D upper_32_bits(ab->phys); - write_buffer->buf_size =3D len; - write_buffer->timestamp_lsw =3D lsw_ts; - write_buffer->timestamp_msw =3D msw_ts; - write_buffer->mem_map_handle =3D graph->info->mem_map_handle; - write_buffer->flags =3D wflags; + scoped_guard(mutex, &graph->lock) { + ab =3D &graph->rx_data.buf[graph->rx_data.dsp_buf]; =20 - graph->rx_data.dsp_buf++; + write_buffer->buf_addr_lsw =3D lower_32_bits(ab->phys); + write_buffer->buf_addr_msw =3D upper_32_bits(ab->phys); + write_buffer->buf_size =3D len; + write_buffer->timestamp_lsw =3D lsw_ts; + write_buffer->timestamp_msw =3D msw_ts; + write_buffer->mem_map_handle =3D graph->info->mem_map_handle; + write_buffer->flags =3D wflags; =20 - if (graph->rx_data.dsp_buf >=3D graph->rx_data.num_periods) - graph->rx_data.dsp_buf =3D 0; + graph->rx_data.dsp_buf++; =20 - mutex_unlock(&graph->lock); + if (graph->rx_data.dsp_buf >=3D graph->rx_data.num_periods) + graph->rx_data.dsp_buf =3D 0; + } =20 return gpr_send_port_pkt(graph->port, pkt); } @@ -493,21 +483,20 @@ int q6apm_read(struct q6apm_graph *graph) =20 read_buffer =3D (void *)pkt + GPR_HDR_SIZE; =20 - mutex_lock(&graph->lock); - port =3D &graph->tx_data; - ab =3D &port->buf[port->dsp_buf]; - - read_buffer->buf_addr_lsw =3D lower_32_bits(ab->phys); - read_buffer->buf_addr_msw =3D upper_32_bits(ab->phys); - read_buffer->mem_map_handle =3D graph->info->mem_map_handle; - read_buffer->buf_size =3D ab->size; + scoped_guard(mutex, &graph->lock) { + port =3D &graph->tx_data; + ab =3D &port->buf[port->dsp_buf]; =20 - port->dsp_buf++; + read_buffer->buf_addr_lsw =3D lower_32_bits(ab->phys); + read_buffer->buf_addr_msw =3D upper_32_bits(ab->phys); + read_buffer->mem_map_handle =3D graph->info->mem_map_handle; + read_buffer->buf_size =3D ab->size; =20 - if (port->dsp_buf >=3D port->num_periods) - port->dsp_buf =3D 0; + port->dsp_buf++; =20 - mutex_unlock(&graph->lock); + if (port->dsp_buf >=3D port->num_periods) + port->dsp_buf =3D 0; + } =20 return gpr_send_port_pkt(graph->port, pkt); } @@ -545,12 +534,12 @@ static int graph_callback(const struct gpr_resp_pkt *= data, void *priv, int op) if (!graph->ar_graph) break; client_event =3D APM_CLIENT_EVENT_DATA_WRITE_DONE; - mutex_lock(&graph->lock); - token =3D hdr->token & APM_WRITE_TOKEN_MASK; + scoped_guard(mutex, &graph->lock) { + token =3D hdr->token & APM_WRITE_TOKEN_MASK; =20 - done =3D data->payload; - phys =3D graph->rx_data.buf[token].phys; - mutex_unlock(&graph->lock); + done =3D data->payload; + phys =3D graph->rx_data.buf[token].phys; + } /* token numbering starts at 0 */ atomic_set(&graph->rx_data.hw_ptr, token + 1); if (lower_32_bits(phys) =3D=3D done->buf_addr_lsw && @@ -569,10 +558,10 @@ static int graph_callback(const struct gpr_resp_pkt *= data, void *priv, int op) if (!graph->ar_graph) break; client_event =3D APM_CLIENT_EVENT_DATA_READ_DONE; - mutex_lock(&graph->lock); - rd_done =3D data->payload; - phys =3D graph->tx_data.buf[hdr->token].phys; - mutex_unlock(&graph->lock); + scoped_guard(mutex, &graph->lock) { + rd_done =3D data->payload; + phys =3D graph->tx_data.buf[hdr->token].phys; + } /* token numbering starts at 0 */ atomic_set(&graph->tx_data.hw_ptr, hdr->token + 1); =20 --=20 2.43.0 From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10F8647279F for ; Wed, 3 Jun 2026 11:50:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487433; cv=none; b=jh1+CcBtbUaSbV0Z58halm7z4bVATIL5XxF2JjsyFatzotTe/+J45MtWiwlv1mUElHTCJV6ZflDS3sfJtlafRsTvgD+7lBSlgu9G8DXV6vT02w8T1kFXFGK6uPa6Q8J8WnyUxta5rA2yIVLmC7TaZ1Se9Y31ewW/NFpFzanxGNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487433; c=relaxed/simple; bh=y6XRfj7uH/twihlvLPQECCeTMtp+zAXGvZHstWObMDU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T06TInBn7938cR7NKIjDvqHO69cbAuQeqvhc8YO/wX5EEfQFd46nEk+a25kT8YTbDgdyvBy9Ov7KF7Ph3Ft9JrBkANRLZfqiOc3ab45ie5FRFr9xa8uexHyb9HvVMRJ9PsOGOcud7dqFt75/8CWOxpk7g3Xx6q58hDoGU0MqjW8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mBJm5luJ; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mBJm5luJ" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2c0b944f6edso37633245ad.2 for ; Wed, 03 Jun 2026 04:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487431; x=1781092231; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CTIltzuE2Za37oaiI+Y4tpXxqTPpmM9bJbC/+luaF7g=; b=mBJm5luJPjy7IFMe57I7DY2wTQx3pdzo1JHNOOlEII937JEuw1tO0WFXQsSCWv8rFm bEumMFdTbTZvTvW3g2suqWKsHgH6D0Ie3i7gJ8rFilIt3YGO503t2j485mvMD/Itxoun qjc5Ie/cwjtiK0LaS9aJjkqkminJRSGBWcEwN2YMX0mWHh754NSEPRYQbb82hwJi9vME rwRVMJcLoafix7qKnjnhz+AbAVS1+javcWziPz/3jbKzzfpsFvw1PySDkBQDub9gNapG m+WcOaUWHRJmCSERRtQ/7fQbGXUTObuggOWYbUs3u5vGTba2Gv+ZzUov39eELyCmBHf1 klUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487431; x=1781092231; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CTIltzuE2Za37oaiI+Y4tpXxqTPpmM9bJbC/+luaF7g=; b=JizjOpAHmkMoSGhfjmiqrHui0k/NbaRWaT+MtykDqGqP2z6N4IvCK3sK74HbsmQHQA b++I8DuxVv8WplDGjKzHWiFgG8zbQaOB+KMVjaeK4jl+qMF5NN03H0oODr20NgswBFRw N8waigl0cs3ryaXu/cz/auyKbSb8p8PnWpt83FnOh/yzuHeudPYMtfzOBvsFB5qlr/4X HnY8Sk9qOSfpxIkiZHNvXYRdcuSDbeYltM/hdgg62vW0+oRgfg6Ao+uUlYwli5jhff/j pyQWOoK2dFne+APaAyl8S3tQO/RXrnD8y4tMZooi7Vy2UpzAmJb7uC3BFj69zbIq128R EuoQ== X-Forwarded-Encrypted: i=1; AFNElJ+nG2wCuCJUc20dZtfbaecEBmHrSJcjuSqEXbcT9S1oHaQL4A2Q+mDZD2+7+tV48zeRsf2SDUgT3oZOVK4=@vger.kernel.org X-Gm-Message-State: AOJu0Yxw8JFYXGvdxtQi0nQ6rAHpuz7YU/JkjH6gNDE/WXSjfqPZC2LA CFmJODhGjnfGnyGG1c/6A2URPKHWaIlJPAexEAKRg7VOk6V4b7XQTNQF X-Gm-Gg: Acq92OEB8NQZha4T65/D0V5qte6BC3ZMV/3bUWs2OR/7mGH2sTirACIS17Qh2kUDIJk yVKFXT8kQhap2qYMpiYlUXS/QRfD0sn3Mzbwh4mdIXseWtIyO28hlP6hwywRARvvMrwY9oGP3dz 60T82i7WoSjSfKH4Xu3c40zSAjKBcEzD2Nxg9oEWW9WfV2G+gRtoD0viLeXfuki6GLSaEI75nWS 4l1gXQEaKqg2zO2Syv0Uv9rP6ChZ8wjbAq9Bk/bHn2XG4ZBicCuJ5ligaV6lkzSC5juvJPQwHsJ RlSvrDzkxagXGA1OCHKV16dQM8zZuNlk9xwFjS00xks2htMC7vEFuAth1xL55Cy8/Fhbg4uZG9V 5nO3aux3MNCmvOgfLGncH8gN0528inLBS6RqTyz1pnuYzvpxsDrNRhbPHfn9IUA82FONUcD2mgI d7kFnNqNUhUmKFp5pjjWLi0e+hTmwBGwf7A/IFoGZKj/fB1QA2vSWLPf4uF3Qb3eNfR5AH X-Received: by 2002:a17:903:b8d:b0:2c0:cbd8:5ff9 with SMTP id d9443c01a7336-2c163fa8268mr32192965ad.21.1780487431250; Wed, 03 Jun 2026 04:50:31 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:30 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 5/9] ASoC: qcom: q6asm: Use guard() for mutex & spin locks Date: Wed, 3 Jun 2026 18:49:45 +0700 Message-ID: <20260603114949.149595-6-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex & spin locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- NOTE: This patch is compile-tested only. sound/soc/qcom/qdsp6/q6asm.c | 164 +++++++++++++++-------------------- 1 file changed, 71 insertions(+), 93 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c index de0bd8fd08ee..d058468c4afa 100644 --- a/sound/soc/qcom/qdsp6/q6asm.c +++ b/sound/soc/qcom/qdsp6/q6asm.c @@ -297,12 +297,12 @@ static int q6asm_apr_send_session_pkt(struct q6asm *a= , struct audio_client *ac, struct apr_hdr *hdr =3D &pkt->hdr; int rc; =20 - mutex_lock(&ac->cmd_lock); + guard(mutex)(&ac->cmd_lock); ac->result.opcode =3D 0; ac->result.status =3D 0; rc =3D apr_send_pkt(a->adev, pkt); if (rc < 0) - goto err; + return rc; =20 if (rsp_opcode) rc =3D wait_event_timeout(a->mem_wait, @@ -323,8 +323,6 @@ static int q6asm_apr_send_session_pkt(struct q6asm *a, = struct audio_client *ac, rc =3D -EINVAL; } =20 -err: - mutex_unlock(&ac->cmd_lock); return rc; } =20 @@ -371,11 +369,8 @@ static int __q6asm_memory_unmap(struct audio_client *a= c, static void q6asm_audio_client_free_buf(struct audio_client *ac, struct audio_port_data *port) { - unsigned long flags; - - spin_lock_irqsave(&ac->lock, flags); - port->num_periods =3D 0; - spin_unlock_irqrestore(&ac->lock, flags); + scoped_guard(spinlock_irqsave, &ac->lock) + port->num_periods =3D 0; kfree(port->buf); port->buf =3D NULL; } @@ -427,7 +422,6 @@ static int __q6asm_memory_map_regions(struct audio_clie= nt *ac, int dir, struct audio_port_data *port =3D NULL; struct audio_buffer *ab =3D NULL; struct apr_pkt *pkt; - unsigned long flags; uint32_t num_regions, buf_sz; int i, pkt_size; =20 @@ -464,17 +458,17 @@ static int __q6asm_memory_map_regions(struct audio_cl= ient *ac, int dir, cmd->num_regions =3D num_regions; cmd->property_flag =3D 0x00; =20 - spin_lock_irqsave(&ac->lock, flags); - port =3D &ac->port[dir]; + scoped_guard(spinlock_irqsave, &ac->lock) { + port =3D &ac->port[dir]; =20 - for (i =3D 0; i < num_regions; i++) { - ab =3D &port->buf[i]; - mregions->shm_addr_lsw =3D lower_32_bits(ab->phys); - mregions->shm_addr_msw =3D upper_32_bits(ab->phys); - mregions->mem_size_bytes =3D buf_sz; - ++mregions; + for (i =3D 0; i < num_regions; i++) { + ab =3D &port->buf[i]; + mregions->shm_addr_lsw =3D lower_32_bits(ab->phys); + mregions->shm_addr_msw =3D upper_32_bits(ab->phys); + mregions->mem_size_bytes =3D buf_sz; + ++mregions; + } } - spin_unlock_irqrestore(&ac->lock, flags); =20 return q6asm_apr_send_session_pkt(a, ac, pkt, ASM_CMDRSP_SHARED_MEM_MAP_R= EGIONS); } @@ -495,38 +489,32 @@ int q6asm_map_memory_regions(unsigned int dir, struct= audio_client *ac, size_t period_sz, unsigned int periods) { struct audio_buffer *buf; - unsigned long flags; int cnt; int rc; =20 - spin_lock_irqsave(&ac->lock, flags); - if (ac->port[dir].buf) { - dev_err(ac->dev, "Buffer already allocated\n"); - spin_unlock_irqrestore(&ac->lock, flags); - return 0; - } - - buf =3D kzalloc_objs(*buf, periods, GFP_ATOMIC); - if (!buf) { - spin_unlock_irqrestore(&ac->lock, flags); - return -ENOMEM; - } + scoped_guard(spinlock_irqsave, &ac->lock) { + if (ac->port[dir].buf) { + dev_err(ac->dev, "Buffer already allocated\n"); + return 0; + } =20 + buf =3D kzalloc_objs(*buf, periods, GFP_ATOMIC); + if (!buf) + return -ENOMEM; =20 - ac->port[dir].buf =3D buf; + ac->port[dir].buf =3D buf; =20 - buf[0].phys =3D phys; - buf[0].size =3D period_sz; + buf[0].phys =3D phys; + buf[0].size =3D period_sz; =20 - for (cnt =3D 1; cnt < periods; cnt++) { - if (period_sz > 0) { - buf[cnt].phys =3D buf[0].phys + (cnt * period_sz); - buf[cnt].size =3D period_sz; + for (cnt =3D 1; cnt < periods; cnt++) { + if (period_sz > 0) { + buf[cnt].phys =3D buf[0].phys + (cnt * period_sz); + buf[cnt].size =3D period_sz; + } } + ac->port[dir].num_periods =3D periods; } - ac->port[dir].num_periods =3D periods; - - spin_unlock_irqrestore(&ac->lock, flags); =20 rc =3D __q6asm_memory_map_regions(ac, dir, period_sz, periods, 1); if (rc < 0) { @@ -542,14 +530,12 @@ static void q6asm_audio_client_release(struct kref *r= ef) { struct audio_client *ac; struct q6asm *a; - unsigned long flags; =20 ac =3D container_of(ref, struct audio_client, refcount); a =3D ac->q6asm; =20 - spin_lock_irqsave(&a->slock, flags); - a->session[ac->session] =3D NULL; - spin_unlock_irqrestore(&a->slock, flags); + scoped_guard(spinlock_irqsave, &a->slock) + a->session[ac->session] =3D NULL; =20 kfree(ac); } @@ -842,7 +828,6 @@ struct audio_client *q6asm_audio_client_alloc(struct de= vice *dev, q6asm_cb cb, { struct q6asm *a =3D dev_get_drvdata(dev->parent); struct audio_client *ac; - unsigned long flags; =20 ac =3D q6asm_get_audio_client(a, session_id + 1); if (ac) { @@ -854,9 +839,8 @@ struct audio_client *q6asm_audio_client_alloc(struct de= vice *dev, q6asm_cb cb, if (!ac) return ERR_PTR(-ENOMEM); =20 - spin_lock_irqsave(&a->slock, flags); - a->session[session_id + 1] =3D ac; - spin_unlock_irqrestore(&a->slock, flags); + scoped_guard(spinlock_irqsave, &a->slock) + a->session[session_id + 1] =3D ac; ac->session =3D session_id + 1; ac->cb =3D cb; ac->dev =3D dev; @@ -880,20 +864,19 @@ static int q6asm_ac_send_cmd_sync(struct audio_client= *ac, struct apr_pkt *pkt) struct apr_hdr *hdr =3D &pkt->hdr; int rc; =20 - mutex_lock(&ac->cmd_lock); + guard(mutex)(&ac->cmd_lock); ac->result.opcode =3D 0; ac->result.status =3D 0; =20 rc =3D apr_send_pkt(ac->adev, pkt); if (rc < 0) - goto err; + return rc; =20 rc =3D wait_event_timeout(ac->cmd_wait, (ac->result.opcode =3D=3D hdr->opcode), 5 * HZ); if (!rc) { dev_err(ac->dev, "CMD %x timeout\n", hdr->opcode); - rc =3D -ETIMEDOUT; - goto err; + return -ETIMEDOUT; } =20 if (ac->result.status > 0) { @@ -904,9 +887,6 @@ static int q6asm_ac_send_cmd_sync(struct audio_client *= ac, struct apr_pkt *pkt) rc =3D 0; } =20 - -err: - mutex_unlock(&ac->cmd_lock); return rc; } =20 @@ -1402,7 +1382,6 @@ int q6asm_read(struct audio_client *ac, uint32_t stre= am_id) struct audio_port_data *port; struct audio_buffer *ab; struct apr_pkt *pkt; - unsigned long flags; int pkt_size =3D APR_HDR_SIZE + sizeof(*read); int rc =3D 0; =20 @@ -1413,25 +1392,25 @@ int q6asm_read(struct audio_client *ac, uint32_t st= ream_id) pkt =3D p; read =3D p + APR_HDR_SIZE; =20 - spin_lock_irqsave(&ac->lock, flags); - port =3D &ac->port[SNDRV_PCM_STREAM_CAPTURE]; - q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id); - ab =3D &port->buf[port->dsp_buf]; - pkt->hdr.opcode =3D ASM_DATA_CMD_READ_V2; - read->buf_addr_lsw =3D lower_32_bits(ab->phys); - read->buf_addr_msw =3D upper_32_bits(ab->phys); - read->mem_map_handle =3D port->mem_map_handle; + scoped_guard(spinlock_irqsave, &ac->lock) { + port =3D &ac->port[SNDRV_PCM_STREAM_CAPTURE]; + q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id); + ab =3D &port->buf[port->dsp_buf]; + pkt->hdr.opcode =3D ASM_DATA_CMD_READ_V2; + read->buf_addr_lsw =3D lower_32_bits(ab->phys); + read->buf_addr_msw =3D upper_32_bits(ab->phys); + read->mem_map_handle =3D port->mem_map_handle; =20 - read->buf_size =3D ab->size; - read->seq_id =3D port->dsp_buf; - pkt->hdr.token =3D port->dsp_buf; + read->buf_size =3D ab->size; + read->seq_id =3D port->dsp_buf; + pkt->hdr.token =3D port->dsp_buf; =20 - port->dsp_buf++; + port->dsp_buf++; =20 - if (port->dsp_buf >=3D port->num_periods) - port->dsp_buf =3D 0; + if (port->dsp_buf >=3D port->num_periods) + port->dsp_buf =3D 0; + } =20 - spin_unlock_irqrestore(&ac->lock, flags); rc =3D apr_send_pkt(ac->adev, pkt); if (rc =3D=3D pkt_size) rc =3D 0; @@ -1515,7 +1494,6 @@ int q6asm_write_async(struct audio_client *ac, uint32= _t stream_id, uint32_t len, struct asm_data_cmd_write_v2 *write; struct audio_port_data *port; struct audio_buffer *ab; - unsigned long flags; struct apr_pkt *pkt; int pkt_size =3D APR_HDR_SIZE + sizeof(*write); int rc =3D 0; @@ -1527,30 +1505,30 @@ int q6asm_write_async(struct audio_client *ac, uint= 32_t stream_id, uint32_t len, pkt =3D p; write =3D p + APR_HDR_SIZE; =20 - spin_lock_irqsave(&ac->lock, flags); - port =3D &ac->port[SNDRV_PCM_STREAM_PLAYBACK]; - q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id); + scoped_guard(spinlock_irqsave, &ac->lock) { + port =3D &ac->port[SNDRV_PCM_STREAM_PLAYBACK]; + q6asm_add_hdr(ac, &pkt->hdr, pkt_size, false, stream_id); =20 - ab =3D &port->buf[port->dsp_buf]; - pkt->hdr.token =3D port->dsp_buf | (len << ASM_WRITE_TOKEN_LEN_SHIFT); - pkt->hdr.opcode =3D ASM_DATA_CMD_WRITE_V2; - write->buf_addr_lsw =3D lower_32_bits(ab->phys); - write->buf_addr_msw =3D upper_32_bits(ab->phys); - write->buf_size =3D len; - write->seq_id =3D port->dsp_buf; - write->timestamp_lsw =3D lsw_ts; - write->timestamp_msw =3D msw_ts; - write->mem_map_handle =3D - ac->port[SNDRV_PCM_STREAM_PLAYBACK].mem_map_handle; + ab =3D &port->buf[port->dsp_buf]; + pkt->hdr.token =3D port->dsp_buf | (len << ASM_WRITE_TOKEN_LEN_SHIFT); + pkt->hdr.opcode =3D ASM_DATA_CMD_WRITE_V2; + write->buf_addr_lsw =3D lower_32_bits(ab->phys); + write->buf_addr_msw =3D upper_32_bits(ab->phys); + write->buf_size =3D len; + write->seq_id =3D port->dsp_buf; + write->timestamp_lsw =3D lsw_ts; + write->timestamp_msw =3D msw_ts; + write->mem_map_handle =3D + ac->port[SNDRV_PCM_STREAM_PLAYBACK].mem_map_handle; =20 - write->flags =3D wflags; + write->flags =3D wflags; =20 - port->dsp_buf++; + port->dsp_buf++; =20 - if (port->dsp_buf >=3D port->num_periods) - port->dsp_buf =3D 0; + if (port->dsp_buf >=3D port->num_periods) + port->dsp_buf =3D 0; + } =20 - spin_unlock_irqrestore(&ac->lock, flags); rc =3D apr_send_pkt(ac->adev, pkt); if (rc =3D=3D pkt_size) rc =3D 0; --=20 2.43.0 From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8B0B47799C for ; Wed, 3 Jun 2026 11:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487436; cv=none; b=qz7Z7NoXbpa7B8hyyhyrLK04+NiDOejDyi6XsqJCDl5VE5s/ejt150bhRvCqFnoq7I6rKYcbvyunMgmLqRtRtyiH8K+RhdU+MpwoPReGopRC3tm/JuT9lrfPQDVc7bh3+WORN0QXGlhGpeH5vEas7/Hv9dtKyu6H8NiSwCczRwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487436; c=relaxed/simple; bh=7vnU2lZPmEEMRduMSMleJemI++ozaYm06y7NJ1dlEEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lG4PRZvbxIuHT8VjOmrzfQOaY2ih7HyDyUX7+e8z6o5pegJQQ/FObXXHaK0A5Zcs5KIWxQ0gX6Bmfew+a9jmeMdO7UpBgDXcyWBdDlCsT3eJ6dQ3aVPGJEJnmqVtQhX66xvGoTTvn75LXXrokq6Eq5+jLYCLpZa1xT20s03uR7Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y7OQnVIe; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y7OQnVIe" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2c168baac83so2825655ad.2 for ; Wed, 03 Jun 2026 04:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487435; x=1781092235; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H0+OuvvQkl90TmM41S9YQoe97Z4NvBQ5dxCyjSxljyU=; b=Y7OQnVIeQ4P4ksLaktt1cMVG78hDlR6Fog9+JLxYhj3WWygUEAEv3LpCVEKaX8DxQE WK/7/Rh+u0ny9eAn/GIPyljwy3ozsHLrzurc+zBEVk1SeS/ShykBLNklSezEADet33UH l4u5Iwf90OgtBdXc9OjDlf/oaJI6gBrIGn5N6U8EuHK1NxnC+2ph2Qke45Cj/zhK5dS+ j5ag/ko/axn2wh0kD6AofQeHPDAGZsxpULTdrqXUhvRcv10vyusyg0Nml099bt/P9AWW nfZ68S9MlkeRqcoUxff+fRLufl+qgQYVPH2jzpkSMkBid6vprWtgcMY/B9giWglLue5F JBKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487435; x=1781092235; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=H0+OuvvQkl90TmM41S9YQoe97Z4NvBQ5dxCyjSxljyU=; b=fkgKrCJzf88xZuEOrljD9pH1WAikus9Xz/22vZB1ksPI03XxdM8UiGV350/f08L35C eGq7Yqy7wt+4X0ljytf8NBTmMWsdH9Z7HHRcHUHvkB0VFtJBSkC1ELXCi6CvDer7lBOC 1DXEeMvdHrJuwo88JkgDbgMDunC4dJajahh314ukaLYPbkK6LbaMpuAfeF+uJD/Db3L3 hTJjdzr3zZX85KOC2RvJyZZcvFXTRn1U4X4lfg3lPFkgUbmNd5kEHr9zZKuOGiGtPiUW Ng6dWIIw8D9y9hOcoE2v3cHMYaNnre0w8lVbk4TCwead1i+UWlTOrYpHGLlo9GynR21p lKCA== X-Forwarded-Encrypted: i=1; AFNElJ8J5TXXrV66td4Q3f64mtBIQLJK5VNLWe5NbOzIxL1LRCf8EwPPX3x1BqNwDfvDm6uCYAveMpkK5q+JYcw=@vger.kernel.org X-Gm-Message-State: AOJu0Yyhkzv17cQLWG04OL1wNQIXc8xfXZTXzE5++KPr3fHkGG+4po3s HZElIRJEfl0VmkU2jKNqucYqR1yupaeSEM2xT4NbjQ9zgBLgVY3amDX1 X-Gm-Gg: Acq92OELh+xBW6KASOX9iFwaQH/1oUSGMl4LeNjJG9SBcEUVO79elRbNkoIBudoCHlE gjjoJd8vHVvhTEnb2tXrzLcE7Ef8anXLhoN1AstB6tPGmhWaq5dvoThlgwXsL5ocdPyzBFd1Uem +cCQ0Sl/Lr8yJFMQQ4JxjCwNF4MpeSXAWSZVaFBgWAa6x+qzj8p+F3ypR85n9W50xkMlirc+FL8 iLz+x1UU6CahsHLqgEFt1hB/3BLEzMbpVFhpVsGWiv4kli/EYGQ/sAyjUYnXsUmafK9fj5WZ3GG 4ZIxliPobaJ9ryB0Q/jMCzcJ5TpZFqcc5i1coYheAEf1VYI2JI3gnPp/NgdqMc/Zs7mlkJk/TSh hTa0THic+x/WavHSLgrb45B5DIeG2iLb8GIDu0B/W0zbBwLd/ra25C9gCg0LC0+rLWGpnw7R3F1 ZeqMUXtTh8MfcZXdD20u6ujS2DbONVO4Sn4pa31Al5lYhJze8+gjAvrE38X8tTV5weu6u7 X-Received: by 2002:a17:903:acd:b0:2c0:bd76:cf18 with SMTP id d9443c01a7336-2c1646df446mr31681185ad.38.1780487434906; Wed, 03 Jun 2026 04:50:34 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:34 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 6/9] ASoC: qdsp6: q6core: Use guard() for mutex locks Date: Wed, 3 Jun 2026 18:49:46 +0700 Message-ID: <20260603114949.149595-7-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- NOTE: This patch is compile-tested only. sound/soc/qcom/qdsp6/q6core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6core.c b/sound/soc/qcom/qdsp6/q6core.c index 48825756a7ab..99cd4ea821a5 100644 --- a/sound/soc/qcom/qdsp6/q6core.c +++ b/sound/soc/qcom/qdsp6/q6core.c @@ -252,7 +252,7 @@ int q6core_get_svc_api_info(int svc_id, struct q6core_s= vc_api_info *ainfo) if (!g_core || !ainfo) return 0; =20 - mutex_lock(&g_core->lock); + guard(mutex)(&g_core->lock); if (!g_core->is_version_requested) { if (q6core_get_fwk_versions(g_core) =3D=3D -ENOTSUPP) q6core_get_svc_versions(g_core); @@ -287,8 +287,6 @@ int q6core_get_svc_api_info(int svc_id, struct q6core_s= vc_api_info *ainfo) } } =20 - mutex_unlock(&g_core->lock); - return ret; } EXPORT_SYMBOL_GPL(q6core_get_svc_api_info); @@ -306,7 +304,7 @@ bool q6core_is_adsp_ready(void) if (!g_core) return false; =20 - mutex_lock(&g_core->lock); + guard(mutex)(&g_core->lock); timeout =3D jiffies + msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS); for (;;) { if (__q6core_is_adsp_ready(g_core)) { @@ -320,7 +318,6 @@ bool q6core_is_adsp_ready(void) } } =20 - mutex_unlock(&g_core->lock); return ret; } EXPORT_SYMBOL_GPL(q6core_is_adsp_ready); --=20 2.43.0 From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26AA6477E21 for ; Wed, 3 Jun 2026 11:50:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487440; cv=none; b=PeZOm5Fu30b4b//F2nJhEKe24iCdQ1CGyYHwbWWqG9M3LOU3zpnZam5n7Q3g9EnV3OTbilY1e/NXTNeDNLme+SfWTH2rrqoHUG+aL95nwItQEPDQ9ZeuiKzh/9B4JC4NtZO+r0ii6uKQuunTE67JD54hC9DSNVNFWY0edphiVO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487440; c=relaxed/simple; bh=jjHgp/jZpuHSIFDNTXOtEU2uGayag8e8wk5Kamgfz9o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H1lBbiBOZKHV/4hT7iyiWsdRI/YmrqZWH4lVdBm4thbs5x021YmwTS6ABOqhh5JCBxAp5WhUaVfQqjJamUeKh14q9iiI1/LvLnUVx/z+262y/ggda+k9P31RrX+x3jNenMD04WpXtz6+csKr88fk3FrXQ35sm6NalpelXXsXOOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TZG2bb6d; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TZG2bb6d" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2c0bb4a94b8so27299605ad.2 for ; Wed, 03 Jun 2026 04:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487438; x=1781092238; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aBfuXDyFUzLNioBdr/HkD5u66fuFdgp5SklAx/I+Qf8=; b=TZG2bb6dCYNAVa7zqIQFWXwqguNGQMn7N7uNmcQxuBrsEfh6fk5JWY6uy1kVigOxLH aeiELEHK1JmDSO9Zc1j23ie1Taguq51F04O89quwnQSLmrQxNbw18xyovnriFmWzm2NB VxLWsgc2X7IlZ2lOF4OqalU5Q9QVpQrceeyouhwv4rKtP4dsr/Bmwe4Zo2NYYgIe7jco TZONWHGQFGDqhb4P+Nc4v7rBVXbCX7LL7hhCm23Qlm6REQx7+ADrN46kSaWZju2qNAqq ieprubN8DyrdLdUKdmswXAcBwejCPD/xlD6MIwMj+0EZhk/laM446YGtIBJy2UC9bNnm d/Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487438; x=1781092238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aBfuXDyFUzLNioBdr/HkD5u66fuFdgp5SklAx/I+Qf8=; b=gVPYlqp2AJRP05uiBZNlAUnLDvUY+wp/f222myrtDJAlBiEbqvnFAzF69bVvpVA+2N EirhHr6NR72FZn2oWuTB5UrFhc8n8z+hsx0+OygaEvihpzG5+zIg8yv5JMMbWIdxXEJR GnyuTw7Xk/pceQiJPPbfnS4wNe44aznWgceAdJ7AYIy+x4XqWJjdhlNsQuV93Ad4vtPW zJDrWfQJeoSQszoBjbLN7Bc6sempD3B52DplCJDxfRGF0aIIGnWbPzsl4vZa7QgBzpKg WwANAhvyau6HaIeTU7PFixoZzaT/t1U8DSCrtiZHZsRan4tYGqtqAaO+CuwMeB4aIgZ2 CnSw== X-Forwarded-Encrypted: i=1; AFNElJ+Mh7JxLEzcyLsAGaeBOZfnGdZDOvb9EcEg0k9kPAMOPGx58K25kJc1tMQFP427opBVs4xFLLeTZ8iJsTU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6g8mF2pfUzhq22Y+V/UBFwbCoERsBzUbd3wI3QAiKCE/gCbvm YEfnkMqo5+IKPSlRDfZ68RO5peI5hdTmM5zw1gYRYFZGSpq5Sc+ULVLv X-Gm-Gg: Acq92OFIMixnqhYC9JLG9/sVKNTAcYUyeTwmTTcVQWBOQoGqdLM4qHglBLuFFJ+Xsup YDfZaRWHThWmGv8ThnMOgYPHZgpwFk/GOg4ikBAjmQ5UasYkarnAj2tII1DEmB5sU43Bg4aM3Uc b/G63dbftSP35pwdO4X3DOceTfeLqI7kaDHJNv3Y/2Bh/bGGNYm/NcfTkunlv1xKbmxM4H2mnSc iqwEYALj8XyEckTty3WUIjMNeZqQT6hTElzqBy95dmGZuYNqPmA4yMthpTqCgykJ91MLnL/MO+A dyum+9ocfBFkw/DhXOrOm/Ep0+Z6uG3F6SPwD4RE8MKJCa4uzOD6K+p+ms4OIlDWT6OWoLyIRO6 et8rmPr3am7xjaz3B3OV2RZsaGfVSsZ11f8hHUJ6AF+O4dCDbwMYEfEbr2d+xOzsuO8uiBhGX4c MXP86Q2l0XLxx/KIiCdk2iGdkJ5+OGNKtK6D3eVdYCQv/ePJZODR2PeaonC/l5BeJc1ZQMb+7Nr 2qpPFM= X-Received: by 2002:a17:903:b08:b0:2bf:77b2:8b2d with SMTP id d9443c01a7336-2c1644a63c5mr34036585ad.30.1780487438458; Wed, 03 Jun 2026 04:50:38 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:38 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 7/9] ASoC: qdsp6: q6routing: Use guard() for mutex locks Date: Wed, 3 Jun 2026 18:49:47 +0700 Message-ID: <20260603114949.149595-8-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- NOTE: This patch is compile-tested only. sound/soc/qcom/qdsp6/q6routing.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6routing.c b/sound/soc/qcom/qdsp6/q6rout= ing.c index 7386226046fa..fff103b9dca1 100644 --- a/sound/soc/qcom/qdsp6/q6routing.c +++ b/sound/soc/qcom/qdsp6/q6routing.c @@ -381,7 +381,7 @@ int q6routing_stream_open(int fedai_id, int perf_mode, =20 pdata =3D &routing_data->port_data[session->port_id]; =20 - mutex_lock(&routing_data->lock); + guard(mutex)(&routing_data->lock); session->fedai_id =3D fedai_id; =20 session->path_type =3D pdata->path_type; @@ -396,10 +396,8 @@ int q6routing_stream_open(int fedai_id, int perf_mode, session->channels, topology, perf_mode, session->bits_per_sample, 0, 0); =20 - if (IS_ERR_OR_NULL(copp)) { - mutex_unlock(&routing_data->lock); + if (IS_ERR_OR_NULL(copp)) return -EINVAL; - } =20 copp_idx =3D q6adm_get_copp_id(copp); set_bit(copp_idx, &session->copp_map); @@ -417,7 +415,6 @@ int q6routing_stream_open(int fedai_id, int perf_mode, q6adm_matrix_map(routing_data->dev, session->path_type, payload, perf_mode); } - mutex_unlock(&routing_data->lock); =20 return 0; } @@ -1070,7 +1067,7 @@ static int routing_hw_params(struct snd_soc_component= *component, =20 session =3D &data->port_data[be_id]; =20 - mutex_lock(&data->lock); + guard(mutex)(&data->lock); =20 session->path_type =3D path_type; session->sample_rate =3D params_rate(params); @@ -1087,7 +1084,6 @@ static int routing_hw_params(struct snd_soc_component= *component, break; } =20 - mutex_unlock(&data->lock); return 0; } =20 --=20 2.43.0 From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22B21477E38 for ; Wed, 3 Jun 2026 11:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487445; cv=none; b=FOxer1ZBmP50STqu2DK3AwAQf5ELSfLxnpUXaxq2kcca+dzVj05fWYV+atmOZbqaQKdcgHtFZHWq0ts4rHeyYFtWDMhzb3Dv+VsFSc+gzdj81hgPNi3AEPpN8MxWwZE09mbwG9fbaoMWcb/Ng9gGYOyz1a1yQ53d2QwiF6hwaqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487445; c=relaxed/simple; bh=mW4eQXqnfxaB0c/JC7r7EXwbppQQR/dLCcxN+G/JGWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=riLFte4OaUdQY6OiOYKPpkfFn8lwhhpIqk8MM9m427yyUIFnWtZo9OjK4/A8mrESZgOyp3xvuI+W34e8xAnLE7p2iVGT2bpnLH1bE43MqUW+3aGU1Z2GxVns7RM8Uc9PC9qgIcfKy0/M0DBhuR76NrDfoFUrhQZ/D5Pq0Aqt7Yw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dOeD0Csh; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dOeD0Csh" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2c0a5354da1so4613335ad.0 for ; Wed, 03 Jun 2026 04:50:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487442; x=1781092242; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v/cb7/Oh3wrVW6lTEgQSTGPGYUEEQIjXPznLNOjAVMo=; b=dOeD0Csh2J9hCpo1AaEEl1z+VNNAE/NsFnLdeIyzE78YecNEmFb8cAdZFGAhzJOLIe pwy93amfXkQO1ilD+mUH4EZfev+CYpfcU9ghQ1RFgFH2iDO6ilBUWt7ypt6qtFH8CG56 +DL1sFCze48VV8uv1hyGALHt4A5hXzGRKg79Ho2Ysv5/FWB0cBiiob4baZOAlJZhMb4K I7KeofRucMuV/HIGtak77/KJ7OG5fKn1nmjMHY0/G7ofwiSKU3OY3NtCSjd+srx/jTLo dH4Cc8LccLrAxSphyy8bALrk7vgoruAmJVppb8m0jtBle1UsCGoXFVN6O1+zzw752QdA fZnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487442; x=1781092242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=v/cb7/Oh3wrVW6lTEgQSTGPGYUEEQIjXPznLNOjAVMo=; b=WEbFlgX8JOlwDSW8yW1RkPebYgzoYS5inK1jYcsH05u0aKuPJ5QIQtEsiydhwHgmZF a2YTJnmj2lHQ4smSlM9WT4YV2fYJ05l+h5gCYleVmVP3wlXUxJSfWhv9Q/qd2SeypAj4 ercl9G5Hu6YEeU5Mp30lQFz2rboauopZgDpiMVIooE2uPs2AjfdjYAibcD1Dt0d0pJdh l9gsiv7VpelJSsqFIvab5e+up9oLSxNXkqTxrfEU33ZIcqev92uSra/snznM8AWVbYHl ziak7Jsr0wEo3ykCeSDCF8QblNf2pprX6JQFVzCXbRlpB3cyDbqqGUBWEKB3k+saSdBD 53gA== X-Forwarded-Encrypted: i=1; AFNElJ/sYtdiWRZ9C7O80hTz8CODClVfTaAZ2My3DloFb1+FamLwke75M7msmA32TE5Al0PsUrfvi7hTRnpkdOs=@vger.kernel.org X-Gm-Message-State: AOJu0YzbIoU8vr+ImKoXygnjhrzsPhdgTSeC8ZTjL8IEbAc3X9Xn/ShS 2n0bpiBlPWN6CyUL+O7f/t0+7JDh7CCmA5+VNBWxVPoIv1y/VVpQCHwj X-Gm-Gg: Acq92OHbj0Ru3D7W+L+tN2OfeKURXFakggjfvIwuXdM308AJdr3deZ3gn7v3zfFhBsm t/j/rcppWc2xtBLLu51IoqPSbhNVYki0JYE5l7A5/Ld5N/3x9+AoHsWd8jZ1OgN84BE67CgbBpu cWhAiTg7/XDWjxbwldWV/nngx7xULNQ1qiKg2O3cC2dNjaBNV7S/vKgXzng30qpvokAc21U0qra qxXxwbGtXzouqHeoxQK946dqeg7BHoSXPkgfGKLzR/d1t0d2fFW4/jDOLXIV4BoKvw6lO+5KeSG d8BViY08Q6yKxkp+UJYZVE1Mx3pS9Hwpmzb3MXByUj7iDHq+CuNJ88W++tR8DdkfRzcR+2nYVk4 jInGfDyCq7R+cRDOZRMNRTZN18YiKCxSB/AlK7/JWmO0XU+BKlCMnBia7CGfxo/hPl4T/LxjEna YPYVzQwdv4O8dhp/ywStY3GA3eyRlbfDM1Enk6w3vgThzrYbmDRnJWqeYQduc0Eq7UquA6 X-Received: by 2002:a17:902:bcc3:b0:2c0:bd40:17e5 with SMTP id d9443c01a7336-2c164b2c190mr16899325ad.19.1780487442382; Wed, 03 Jun 2026 04:50:42 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:41 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 8/9] ASoC: qdsp6: q6usb: Use guard() for mutex locks Date: Wed, 3 Jun 2026 18:49:48 +0700 Message-ID: <20260603114949.149595-9-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- NOTE: This patch is compile-tested only. sound/soc/qcom/qdsp6/q6usb.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c index 6381b289c55c..ee6de9635342 100644 --- a/sound/soc/qcom/qdsp6/q6usb.c +++ b/sound/soc/qcom/qdsp6/q6usb.c @@ -61,31 +61,28 @@ static int q6usb_hw_params(struct snd_pcm_substream *su= bstream, struct snd_soc_usb_device *sdev; int ret =3D -EINVAL; =20 - mutex_lock(&data->mutex); + guard(mutex)(&data->mutex); =20 /* No active chip index */ if (list_empty(&data->devices)) - goto out; + return ret; =20 sdev =3D list_last_entry(&data->devices, struct snd_soc_usb_device, list); =20 ret =3D snd_soc_usb_find_supported_format(sdev->chip_idx, params, directi= on); if (ret < 0) - goto out; + return ret; =20 q6usb_afe =3D q6afe_port_get_from_id(cpu_dai->dev, USB_RX); if (IS_ERR(q6usb_afe)) { ret =3D PTR_ERR(q6usb_afe); - goto out; + return ret; } =20 /* Notify audio DSP about the devices being offloaded */ ret =3D afe_port_send_usb_dev_param(q6usb_afe, sdev->card_idx, sdev->ppcm_idx[sdev->num_playback - 1]); =20 -out: - mutex_unlock(&data->mutex); - return ret; } =20 @@ -203,15 +200,14 @@ static int q6usb_update_offload_route(struct snd_soc_= component *component, int c { struct q6usb_port_data *data =3D dev_get_drvdata(component->dev); struct snd_soc_usb_device *sdev; - int ret =3D 0; int idx =3D -1; =20 - mutex_lock(&data->mutex); + guard(mutex)(&data->mutex); =20 if (list_empty(&data->devices) || direction =3D=3D SNDRV_PCM_STREAM_CAPTURE) { - ret =3D -ENODEV; - goto out; + route[0] =3D idx; + return -ENODEV; } =20 sdev =3D list_last_entry(&data->devices, struct snd_soc_usb_device, list); @@ -227,11 +223,9 @@ static int q6usb_update_offload_route(struct snd_soc_c= omponent *component, int c q6usb_get_pcm_id(component); } =20 -out: route[0] =3D idx; - mutex_unlock(&data->mutex); =20 - return ret; + return 0; } =20 static int q6usb_alsa_connection_cb(struct snd_soc_usb *usb, @@ -244,7 +238,7 @@ static int q6usb_alsa_connection_cb(struct snd_soc_usb = *usb, =20 data =3D dev_get_drvdata(usb->component->dev); =20 - mutex_lock(&data->mutex); + guard(mutex)(&data->mutex); if (connected) { if (data->hs_jack) snd_jack_report(data->hs_jack->jack, SND_JACK_USB); @@ -257,7 +251,6 @@ static int q6usb_alsa_connection_cb(struct snd_soc_usb = *usb, if (data->hs_jack) snd_jack_report(data->hs_jack->jack, 0); } - mutex_unlock(&data->mutex); =20 return 0; } @@ -284,12 +277,11 @@ static int q6usb_component_set_jack(struct snd_soc_co= mponent *component, { struct q6usb_port_data *data =3D dev_get_drvdata(component->dev); =20 - mutex_lock(&data->mutex); + guard(mutex)(&data->mutex); if (jack) q6usb_component_enable_jack(data, jack); else q6usb_component_disable_jack(data); - mutex_unlock(&data->mutex); =20 return 0; } --=20 2.43.0 From nobody Mon Jun 8 07:21:49 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9420B47279D for ; Wed, 3 Jun 2026 11:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487447; cv=none; b=kJjR3SnZjnQklNndVBY5nlEzDxiPhjouu1O9jFreWYituiCOnPHihLXLm97uD4NBpZbv+BiIgGKn4DQJsx5zFbXAmUsQMguA76WMBGH2QbUpkk2FYnM7ke5WSCeaBJm8yEAfoMbcJl/qIrqvoyAA4vSggy0p+ml0NpbC1xKk89U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780487447; c=relaxed/simple; bh=pw1Xomz8P67jYUl18bj/VcuHb5qLX1jm74fDqyanzgU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=koyk7dykkXNsL42vXAVi2J1RuM5JmFJk380CgstKEMHi/vSvC+w7IEMUlm47iYTIM6epua6301hRbGA4E9pgLqxfQZMLOODLjkYCWd74hRSBir/Wqjc4linDzYXY482iy2qUF/K4bvHn2dqJy6NexVZU4Ut2iRZiJz3NTeC2JZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UCs1iEYa; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UCs1iEYa" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2c0c1e0d00bso34961925ad.0 for ; Wed, 03 Jun 2026 04:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780487446; x=1781092246; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rL5+qjOA7bv12mhMT3uoOE5lmwvzw8y82TwvGRMCpDE=; b=UCs1iEYaELn+qjPDFLJgnNcL+kDTPSFOhU6U7xvJ0DyxlT/zvb7SxulAlt7tjym5dc ETvjKcmvaRcbcjtq/bCSp9BTXNjJO41K9fsW4bEAu/QfJsL53YYY2P262qSAUj2044xZ 7QJIaUHrTGHHxZmrDQPppqWO5VZCU/iATJEfhPFvF3nKIVjqfMEJSmUivZZWK5PtScsN hX35Sys4Hb4ybRij+xh0sgXk/yt/9kcqXjQzNKI/D58go9/j2mJPZZ2iKWx9xvkofWQ3 v8iXz3XrDa2Ab13ix9gBgOeau9DsI08pCLqfOhs7gBp1uUeauDroBr23rjm8X90TJH94 B42g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780487446; x=1781092246; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rL5+qjOA7bv12mhMT3uoOE5lmwvzw8y82TwvGRMCpDE=; b=CZccyClq1D+NUx7QCOdhhKhUH2wR6VQX5L09N9rQVT66ReyrE9EuBTRYA+AgF2z4pB nyAxKnXfeeQgxebzRGP+3O5LdX7J9H5gZB7W4/qgqiFlBRedQRCO4XGQfCR2uEW7K/B9 B4F2Tmy3ZCGXY8qz5vBDgmoT2iB0ZUoiqDE799nqHKwiyk6e4qrvNfJRI3s79EcxpuUh Vm/5XjWOWigor6mEFZhEn9CIgiOSun1shKiYuoN9H2VdOAEDVGp1j3OY9CpqLVDt/8jX kwH74cthIHP8Ow1N6NzYEMzIZTQX6zCk/cOIfjL2s2liEvtAPBiCIHVmRMXiUfnOIU8F UBwg== X-Forwarded-Encrypted: i=1; AFNElJ9Nrg500IAvBZGaVIdXxhUQ6rCJTXo5LzVR9+BB8Ini82fYSDKvTBmGSwErRxSNNKPJeaUaurKlDl7ixjI=@vger.kernel.org X-Gm-Message-State: AOJu0YwIAjBpQA94z4wb8PsJNZlMz8GDfRD3+zaxBJ5u2OaRfMyJMTy6 Or3Ft0RS0iZJRFebbLQ0Jd3ZIavPt0SDv9CvdW4vBah66jKsMqSvOkS7 X-Gm-Gg: Acq92OEAFUOlspph9KQzG2NwSHpwMbBob2Kp+DLebLd3QLIMz7zqZ8cOGHps7jWlXHG 9v/T6tk9fTMICoEgPxDO6x7MBBW2P3qEi+A6dr9VWGdLgWbNQ+J8X/z0EU05wVIJ1HPMgA9PQzk 8db2T/b03Ju+zQ4i2KK4rW+rKrW/54HqnPYHS6rjfODqXDTXcmVvQvqkCvNk1PbxTAxo7dF+5Zq Rnd7tNB0LJUyPLKHsZo//Nrq9ATMcoTfsG3Pj1+0Ejz+b1EGA/4p7jrj4hninHR7SPAiX0GevjU fL61Wz8sDyKq2uNPmqYwnoUPH20IN+qd/axUojtmmP9WN3Vy+3iZUxmL/jbJQkenv10nuTRErFd eC8TIYrD88X54dkCodY8HR4FqJNRc5EqoPj6kvQyEpB7P6bi0Tzy2FWoXF3yvVmfMoX6YHW8jtl wqbX/E3GrfryGTDx+0CeJN2EnEHA6ITIhd7TNB59oibZb489Lc1LjVpZDKN5yMbY5lRH6F X-Received: by 2002:a17:903:244c:b0:2c1:77cd:fb0b with SMTP id d9443c01a7336-2c177cdfbfemr14896165ad.37.1780487445843; Wed, 03 Jun 2026 04:50:45 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df63sm22731455ad.40.2026.06.03.04.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 04:50:45 -0700 (PDT) From: phucduc.bui@gmail.com To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Krzysztof Kozlowski , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH 9/9] ASoC: qcom: topology: Use guard() for mutex locks Date: Wed, 3 Jun 2026 18:49:49 +0700 Message-ID: <20260603114949.149595-10-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com> References: <20260603114949.149595-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: bui duc phuc Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc --- NOTE: This patch is compile-tested only. sound/soc/qcom/qdsp6/topology.c | 71 +++++++++++++++------------------ 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topolog= y.c index 1f69fba6de26..efbbebb8c6d3 100644 --- a/sound/soc/qcom/qdsp6/topology.c +++ b/sound/soc/qcom/qdsp6/topology.c @@ -32,9 +32,8 @@ static struct audioreach_graph_info *audioreach_tplg_allo= c_graph_info(struct q6a struct audioreach_graph_info *info; int ret; =20 - mutex_lock(&apm->lock); - info =3D idr_find(&apm->graph_info_idr, graph_id); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + info =3D idr_find(&apm->graph_info_idr, graph_id); =20 if (info) { *found =3D true; @@ -48,9 +47,8 @@ static struct audioreach_graph_info *audioreach_tplg_allo= c_graph_info(struct q6a =20 INIT_LIST_HEAD(&info->sg_list); =20 - mutex_lock(&apm->lock); - ret =3D idr_alloc_u32(&apm->graph_info_idr, info, &graph_id, graph_id, GF= P_KERNEL); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + ret =3D idr_alloc_u32(&apm->graph_info_idr, info, &graph_id, graph_id, G= FP_KERNEL); =20 if (ret < 0) { dev_err(apm->dev, "Failed to allocate Graph ID (%x)\n", graph_id); @@ -82,9 +80,8 @@ static struct audioreach_sub_graph *audioreach_tplg_alloc= _sub_graph(struct q6apm return ERR_PTR(-EINVAL); =20 /* Find if there is already a matching sub-graph */ - mutex_lock(&apm->lock); - sg =3D idr_find(&apm->sub_graphs_idr, sub_graph_id); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + sg =3D idr_find(&apm->sub_graphs_idr, sub_graph_id); =20 if (sg) { *found =3D true; @@ -98,9 +95,10 @@ static struct audioreach_sub_graph *audioreach_tplg_allo= c_sub_graph(struct q6apm =20 INIT_LIST_HEAD(&sg->container_list); =20 - mutex_lock(&apm->lock); - ret =3D idr_alloc_u32(&apm->sub_graphs_idr, sg, &sub_graph_id, sub_graph_= id, GFP_KERNEL); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + ret =3D idr_alloc_u32(&apm->sub_graphs_idr, sg, + &sub_graph_id, sub_graph_id, + GFP_KERNEL); =20 if (ret < 0) { dev_err(apm->dev, "Failed to allocate Sub-Graph Instance ID (%x)\n", sub= _graph_id); @@ -124,9 +122,8 @@ static struct audioreach_container *audioreach_tplg_all= oc_container(struct q6apm if (!container_id) return ERR_PTR(-EINVAL); =20 - mutex_lock(&apm->lock); - cont =3D idr_find(&apm->containers_idr, container_id); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + cont =3D idr_find(&apm->containers_idr, container_id); =20 if (cont) { *found =3D true; @@ -140,9 +137,10 @@ static struct audioreach_container *audioreach_tplg_al= loc_container(struct q6apm =20 INIT_LIST_HEAD(&cont->modules_list); =20 - mutex_lock(&apm->lock); - ret =3D idr_alloc_u32(&apm->containers_idr, cont, &container_id, containe= r_id, GFP_KERNEL); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + ret =3D idr_alloc_u32(&apm->containers_idr, cont, + &container_id, container_id, + GFP_KERNEL); =20 if (ret < 0) { dev_err(apm->dev, "Failed to allocate Container Instance ID (%x)\n", con= tainer_id); @@ -167,9 +165,8 @@ static struct audioreach_module *audioreach_tplg_alloc_= module(struct q6apm *apm, struct audioreach_module *mod; int ret; =20 - mutex_lock(&apm->lock); - mod =3D idr_find(&apm->modules_idr, module_id); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + mod =3D idr_find(&apm->modules_idr, module_id); =20 if (mod) { *found =3D true; @@ -180,15 +177,17 @@ static struct audioreach_module *audioreach_tplg_allo= c_module(struct q6apm *apm, if (!mod) return ERR_PTR(-ENOMEM); =20 - mutex_lock(&apm->lock); - if (!module_id) { /* alloc module id dynamically */ - ret =3D idr_alloc_cyclic(&apm->modules_idr, mod, - AR_MODULE_DYNAMIC_INSTANCE_ID_START, - AR_MODULE_DYNAMIC_INSTANCE_ID_END, GFP_KERNEL); - } else { - ret =3D idr_alloc_u32(&apm->modules_idr, mod, &module_id, module_id, GFP= _KERNEL); + scoped_guard(mutex, &apm->lock) { + if (!module_id) { /* alloc module id dynamically */ + ret =3D idr_alloc_cyclic(&apm->modules_idr, mod, + AR_MODULE_DYNAMIC_INSTANCE_ID_START, + AR_MODULE_DYNAMIC_INSTANCE_ID_END, GFP_KERNEL); + } else { + ret =3D idr_alloc_u32(&apm->modules_idr, mod, + &module_id, module_id, + GFP_KERNEL); + } } - mutex_unlock(&apm->lock); =20 if (ret < 0) { dev_err(apm->dev, "Failed to allocate Module Instance ID (%x)\n", module= _id); @@ -966,7 +965,7 @@ static int audioreach_widget_unload(struct snd_soc_comp= onent *scomp, =20 cont =3D mod->container; =20 - mutex_lock(&apm->lock); + guard(mutex)(&apm->lock); idr_remove(&apm->modules_idr, mod->instance_id); cont->num_modules--; =20 @@ -997,8 +996,6 @@ static int audioreach_widget_unload(struct snd_soc_comp= onent *scomp, } } =20 - mutex_unlock(&apm->lock); - return 0; } =20 @@ -1106,9 +1103,8 @@ static void audioreach_connect_sub_graphs(struct q6ap= m *apm, { struct audioreach_graph_info *info; =20 - mutex_lock(&apm->lock); - info =3D idr_find(&apm->graph_info_idr, m2->graph_id); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + info =3D idr_find(&apm->graph_info_idr, m2->graph_id); =20 if (connect) { info->src_mod_inst_id =3D m1->module_instance_id; @@ -1130,9 +1126,8 @@ static bool audioreach_is_vmixer_connected(struct q6a= pm *apm, { const struct audioreach_graph_info *info; =20 - mutex_lock(&apm->lock); - info =3D idr_find(&apm->graph_info_idr, m2->graph_id); - mutex_unlock(&apm->lock); + scoped_guard(mutex, &apm->lock) + info =3D idr_find(&apm->graph_info_idr, m2->graph_id); =20 if (info->dst_mod_inst_id =3D=3D m2->module_instance_id && info->src_mod_inst_id =3D=3D m1->module_instance_id) --=20 2.43.0