From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>,
Liam Girdwood <liam.r.girdwood@linux.intel.com>,
Cezary Rojewski <cezary.rojewski@intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 15/20] ASoC: Intel: atom: sst_stream: Use guard() for mutex locks
Date: Thu, 11 Jun 2026 18:58:56 +0700 [thread overview]
Message-ID: <20260611115901.80438-16-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20260611115901.80438-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
Clean up the code using guard() for mutex locks.
Additionally, simplify sst_free_stream() while
converting the locking code.
No functional change intended.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/intel/atom/sst/sst_stream.c | 52 ++++++++++++---------------
1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c
index 288221db7323..d2d6ed6df661 100644
--- a/sound/soc/intel/atom/sst/sst_stream.c
+++ b/sound/soc/intel/atom/sst/sst_stream.c
@@ -265,9 +265,8 @@ int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int str_id)
str_info->status = STREAM_PAUSED;
} else if (retval == -SST_ERR_INVALID_STREAM_ID) {
retval = -EINVAL;
- mutex_lock(&sst_drv_ctx->sst_lock);
- sst_clean_stream(str_info);
- mutex_unlock(&sst_drv_ctx->sst_lock);
+ scoped_guard(mutex, &sst_drv_ctx->sst_lock)
+ sst_clean_stream(str_info);
}
} else {
retval = -EBADRQC;
@@ -332,9 +331,8 @@ int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int str_id)
str_info->prev = STREAM_PAUSED;
} else if (retval == -SST_ERR_INVALID_STREAM_ID) {
retval = -EINVAL;
- mutex_lock(&sst_drv_ctx->sst_lock);
- sst_clean_stream(str_info);
- mutex_unlock(&sst_drv_ctx->sst_lock);
+ scoped_guard(mutex, &sst_drv_ctx->sst_lock)
+ sst_clean_stream(str_info);
}
} else {
retval = -EBADRQC;
@@ -433,39 +431,35 @@ int sst_free_stream(struct intel_sst_drv *sst_drv_ctx, int str_id)
dev_dbg(sst_drv_ctx->dev, "SST DBG:sst_free_stream for %d\n", str_id);
- mutex_lock(&sst_drv_ctx->sst_lock);
- if (sst_drv_ctx->sst_state == SST_RESET) {
- mutex_unlock(&sst_drv_ctx->sst_lock);
- return -ENODEV;
+ scoped_guard(mutex, &sst_drv_ctx->sst_lock) {
+ if (sst_drv_ctx->sst_state == SST_RESET)
+ return -ENODEV;
}
- mutex_unlock(&sst_drv_ctx->sst_lock);
str_info = get_stream_info(sst_drv_ctx, str_id);
if (!str_info)
return -EINVAL;
- mutex_lock(&str_info->lock);
- if (str_info->status != STREAM_UN_INIT) {
+ scoped_guard(mutex, &str_info->lock) {
+ if (str_info->status == STREAM_UN_INIT) {
+ dev_dbg(sst_drv_ctx->dev, "SST DBG:BADQRC for stream\n");
+ return -EBADRQC;
+ }
str_info->prev = str_info->status;
str_info->status = STREAM_UN_INIT;
- mutex_unlock(&str_info->lock);
+ }
- dev_dbg(sst_drv_ctx->dev, "Free for str %d pipe %#x\n",
- str_id, str_info->pipe_id);
- retval = sst_prepare_and_post_msg(sst_drv_ctx, str_info->task_id, IPC_CMD,
- IPC_IA_FREE_STREAM_MRFLD, str_info->pipe_id, 0,
- NULL, NULL, true, true, false, true);
+ dev_dbg(sst_drv_ctx->dev, "Free for str %d pipe %#x\n", str_id, str_info->pipe_id);
+
+ retval = sst_prepare_and_post_msg(sst_drv_ctx, str_info->task_id, IPC_CMD,
+ IPC_IA_FREE_STREAM_MRFLD, str_info->pipe_id, 0,
+ NULL, NULL, true, true, false, true);
+
+ dev_dbg(sst_drv_ctx->dev, "sst: wait for free returned %d\n", retval);
- dev_dbg(sst_drv_ctx->dev, "sst: wait for free returned %d\n",
- retval);
- mutex_lock(&sst_drv_ctx->sst_lock);
+ scoped_guard(mutex, &sst_drv_ctx->sst_lock)
sst_clean_stream(str_info);
- mutex_unlock(&sst_drv_ctx->sst_lock);
- dev_dbg(sst_drv_ctx->dev, "SST DBG:Stream freed\n");
- } else {
- mutex_unlock(&str_info->lock);
- retval = -EBADRQC;
- dev_dbg(sst_drv_ctx->dev, "SST DBG:BADQRC for stream\n");
- }
+
+ dev_dbg(sst_drv_ctx->dev, "SST DBG:Stream freed\n");
return retval;
}
--
2.43.0
next prev parent reply other threads:[~2026-06-11 12:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 11:58 [PATCH 00/20] ASoC: Intel: Use guard() for mutex & spin locks phucduc.bui
2026-06-11 11:58 ` [PATCH 01/20] ASoC: Intel: catpt: ipc: " phucduc.bui
2026-06-11 18:44 ` Cezary Rojewski
2026-06-11 11:58 ` [PATCH 02/20] ASoC: Intel: catpt: dsp: Use guard() for mutex locks phucduc.bui
2026-06-11 18:39 ` Cezary Rojewski
2026-06-11 11:58 ` [PATCH 03/20] ASoC: Intel: avs: utils: " phucduc.bui
2026-06-11 11:58 ` [PATCH 04/20] ASoC: Intel: avs: probes: Use guard() for spin locks phucduc.bui
2026-06-11 19:34 ` Cezary Rojewski
2026-06-11 11:58 ` [PATCH 05/20] ASoC: Intel: avs: pcm: Use guard() for mutex & " phucduc.bui
2026-06-11 11:58 ` [PATCH 06/20] ASoC: Intel: avs: path: " phucduc.bui
2026-06-11 11:58 ` [PATCH 07/20] ASoC: Intel: avs: loader: Use guard() for mutex locks phucduc.bui
2026-06-11 11:58 ` [PATCH 08/20] ASoC: Intel: avs: ipc: Use guard() for mutex & spin locks phucduc.bui
2026-06-11 11:58 ` [PATCH 09/20] ASoC: Intel: avs: icl: Use guard() for " phucduc.bui
2026-06-11 11:58 ` [PATCH 10/20] ASoC: Intel: avs: debugfs: " phucduc.bui
2026-06-11 11:58 ` [PATCH 11/20] ASoC: Intel: avs: debug: " phucduc.bui
2026-06-11 11:58 ` [PATCH 12/20] ASoC: Intel: avs: core: Use guard() for mutex & " phucduc.bui
2026-06-11 11:58 ` [PATCH 13/20] ASoC: Intel: avs: control: Use guard() for " phucduc.bui
2026-06-11 11:58 ` [PATCH 14/20] ASoC: Intel: avs: apl: " phucduc.bui
2026-06-11 11:58 ` phucduc.bui [this message]
2026-06-11 11:58 ` [PATCH 16/20] ASoC: Intel: atom: sst_pvt: Use guard() for mutex & " phucduc.bui
2026-06-11 11:58 ` [PATCH 17/20] ASoC: Intel: atom: sst: Use guard() for " phucduc.bui
2026-06-11 11:58 ` [PATCH 18/20] ASoC: Intel: atom: sst-atom-controls: Use guard() for mutex locks phucduc.bui
2026-06-11 11:59 ` [PATCH 19/20] ASoC: Intel: atom: sst-mfld-platform-pcm: Use guard() for mutex & spin locks phucduc.bui
2026-06-11 11:59 ` [PATCH 20/20] ASoC: Intel: atom: sst_ipc: Use guard() for " phucduc.bui
2026-06-11 19:04 ` [PATCH 00/20] ASoC: Intel: Use guard() for mutex & " Cezary Rojewski
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=20260611115901.80438-16-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.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