From: phucduc.bui@gmail.com
To: Srinivas Kandagatla <srini@kernel.org>, Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>,
linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 8/9] ASoC: qdsp6: q6usb: Use guard() for mutex locks
Date: Wed, 3 Jun 2026 18:49:48 +0700 [thread overview]
Message-ID: <20260603114949.149595-9-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20260603114949.149595-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
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 *substream,
struct snd_soc_usb_device *sdev;
int ret = -EINVAL;
- mutex_lock(&data->mutex);
+ guard(mutex)(&data->mutex);
/* No active chip index */
if (list_empty(&data->devices))
- goto out;
+ return ret;
sdev = list_last_entry(&data->devices, struct snd_soc_usb_device, list);
ret = snd_soc_usb_find_supported_format(sdev->chip_idx, params, direction);
if (ret < 0)
- goto out;
+ return ret;
q6usb_afe = q6afe_port_get_from_id(cpu_dai->dev, USB_RX);
if (IS_ERR(q6usb_afe)) {
ret = PTR_ERR(q6usb_afe);
- goto out;
+ return ret;
}
/* Notify audio DSP about the devices being offloaded */
ret = afe_port_send_usb_dev_param(q6usb_afe, sdev->card_idx,
sdev->ppcm_idx[sdev->num_playback - 1]);
-out:
- mutex_unlock(&data->mutex);
-
return ret;
}
@@ -203,15 +200,14 @@ static int q6usb_update_offload_route(struct snd_soc_component *component, int c
{
struct q6usb_port_data *data = dev_get_drvdata(component->dev);
struct snd_soc_usb_device *sdev;
- int ret = 0;
int idx = -1;
- mutex_lock(&data->mutex);
+ guard(mutex)(&data->mutex);
if (list_empty(&data->devices) ||
direction == SNDRV_PCM_STREAM_CAPTURE) {
- ret = -ENODEV;
- goto out;
+ route[0] = idx;
+ return -ENODEV;
}
sdev = list_last_entry(&data->devices, struct snd_soc_usb_device, list);
@@ -227,11 +223,9 @@ static int q6usb_update_offload_route(struct snd_soc_component *component, int c
q6usb_get_pcm_id(component);
}
-out:
route[0] = idx;
- mutex_unlock(&data->mutex);
- return ret;
+ return 0;
}
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,
data = dev_get_drvdata(usb->component->dev);
- 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);
return 0;
}
@@ -284,12 +277,11 @@ static int q6usb_component_set_jack(struct snd_soc_component *component,
{
struct q6usb_port_data *data = dev_get_drvdata(component->dev);
- 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);
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-06-03 11:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 11:49 [PATCH 0/9] ASoC: qcom: Use guard() for mutex & spin locks phucduc.bui
2026-06-03 11:49 ` [PATCH 1/9] ASoC: qcom: audioreach: Use guard() for mutex locks phucduc.bui
2026-06-03 11:49 ` [PATCH 2/9] ASoc: qcom: q6adm: Use guard() for mutex & spin locks phucduc.bui
2026-06-03 11:49 ` [PATCH 3/9] ASoc: qcom: q6afe: Use guard() for mutex locks phucduc.bui
2026-06-03 11:49 ` [PATCH 4/9] ASoC: qcom: q6apm: " phucduc.bui
2026-06-03 11:49 ` [PATCH 5/9] ASoC: qcom: q6asm: Use guard() for mutex & spin locks phucduc.bui
2026-06-03 11:49 ` [PATCH 6/9] ASoC: qdsp6: q6core: Use guard() for mutex locks phucduc.bui
2026-06-03 11:49 ` [PATCH 7/9] ASoC: qdsp6: q6routing: " phucduc.bui
2026-06-03 11:49 ` phucduc.bui [this message]
2026-06-03 11:49 ` [PATCH 9/9] ASoC: qcom: topology: " phucduc.bui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260603114949.149595-9-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=broonie@kernel.org \
--cc=krzysztof.kozlowski@oss.qualcomm.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=srini@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox