ASoC: Intel: avs: Use scoped_guard() for scoped locking

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

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20260626082904.32344-3-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
bui duc phuc 2026-06-26 15:29:01 +07:00 committed by Mark Brown
parent f16513ffa9
commit 6aaac9f6ba
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
3 changed files with 41 additions and 41 deletions

View File

@ -6,6 +6,7 @@
// Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
//
#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/kfifo.h>
#include <linux/wait.h>
@ -251,24 +252,22 @@ static int strace_release(struct inode *inode, struct file *file)
union avs_notify_msg msg = AVS_NOTIFICATION(LOG_BUFFER_STATUS);
struct avs_dev *adev = file->private_data;
unsigned long resource_mask;
unsigned long flags, i;
unsigned long i;
u32 num_cores;
resource_mask = adev->logged_resources;
num_cores = adev->hw_cfg.dsp_cores;
spin_lock_irqsave(&adev->trace_lock, flags);
scoped_guard(spinlock_irqsave, &adev->trace_lock) {
/* Gather any remaining logs. */
for_each_set_bit(i, &resource_mask, num_cores) {
msg.log.core = i;
avs_dsp_op(adev, log_buffer_status, &msg);
}
/* Gather any remaining logs. */
for_each_set_bit(i, &resource_mask, num_cores) {
msg.log.core = i;
avs_dsp_op(adev, log_buffer_status, &msg);
kfifo_free(&adev->trace_fifo);
}
kfifo_free(&adev->trace_fifo);
spin_unlock_irqrestore(&adev->trace_lock, flags);
module_put(adev->dev->driver->owner);
return 0;
}

View File

@ -100,39 +100,39 @@ static void avs_dsp_recovery(struct avs_dev *adev)
unsigned int core_mask;
int ret;
mutex_lock(&adev->comp_list_mutex);
/* disconnect all running streams */
list_for_each_entry(acomp, &adev->comp_list, node) {
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_card *card;
scoped_guard(mutex, &adev->comp_list_mutex) {
/* disconnect all running streams */
list_for_each_entry(acomp, &adev->comp_list, node) {
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_card *card;
card = acomp->base.card;
if (!card)
continue;
for_each_card_rtds(card, rtd) {
struct snd_pcm *pcm;
int dir;
pcm = rtd->pcm;
if (!pcm || rtd->dai_link->no_pcm)
card = acomp->base.card;
if (!card)
continue;
for_each_pcm_streams(dir) {
struct snd_pcm_substream *substream;
for_each_card_rtds(card, rtd) {
struct snd_pcm *pcm;
int dir;
substream = pcm->streams[dir].substream;
if (!substream || !substream->runtime)
pcm = rtd->pcm;
if (!pcm || rtd->dai_link->no_pcm)
continue;
/* No need for _irq() as we are in nonatomic context. */
snd_pcm_stream_lock(substream);
snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
snd_pcm_stream_unlock(substream);
for_each_pcm_streams(dir) {
struct snd_pcm_substream *substream;
substream = pcm->streams[dir].substream;
if (!substream || !substream->runtime)
continue;
/* No need for _irq() as we are in nonatomic context. */
snd_pcm_stream_lock(substream);
snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
snd_pcm_stream_unlock(substream);
}
}
}
}
mutex_unlock(&adev->comp_list_mutex);
/* forcibly shutdown all cores */
core_mask = GENMASK(adev->hw_cfg.dsp_cores - 1, 0);

View File

@ -6,6 +6,7 @@
// Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
//
#include <linux/cleanup.h>
#include <linux/firmware.h>
#include <linux/module.h>
#include <linux/slab.h>
@ -630,15 +631,15 @@ static int avs_load_firmware(struct avs_dev *adev, bool purge)
if (ret)
goto reenable_gating;
mutex_lock(&adev->comp_list_mutex);
list_for_each_entry(acomp, &adev->comp_list, node) {
struct avs_tplg *tplg = acomp->tplg;
scoped_guard(mutex, &adev->comp_list_mutex) {
list_for_each_entry(acomp, &adev->comp_list, node) {
struct avs_tplg *tplg = acomp->tplg;
ret = avs_dsp_load_libraries(adev, tplg->libs, tplg->num_libs);
if (ret < 0)
break;
ret = avs_dsp_load_libraries(adev, tplg->libs, tplg->num_libs);
if (ret < 0)
break;
}
}
mutex_unlock(&adev->comp_list_mutex);
reenable_gating:
avs_hda_l1sen_enable(adev, true);