mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 20:42:29 -04:00
ASoC: SOF: Intel: Use guard()/scoped_guard() for mutex locks where it makes sense
Replace the manual mutex lock/unlock pairs with guard()/scoped_guard(). Only code refactoring, and no behavior change. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://patch.msgid.link/20260112101004.7648-3-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
5c19da34df
commit
599a5b00a1
@@ -311,7 +311,7 @@ static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cp
|
||||
if (pipe_widget->instance_id < 0)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&ipc4_data->pipeline_state_mutex);
|
||||
guard(mutex)(&ipc4_data->pipeline_state_mutex);
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
@@ -323,16 +323,16 @@ static int hda_ipc4_pre_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cp
|
||||
ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id,
|
||||
SOF_IPC4_PIPE_PAUSED);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
pipeline->state = SOF_IPC4_PIPE_PAUSED;
|
||||
|
||||
break;
|
||||
default:
|
||||
dev_err(sdev->dev, "unknown trigger command %d\n", cmd);
|
||||
ret = -EINVAL;
|
||||
}
|
||||
out:
|
||||
mutex_unlock(&ipc4_data->pipeline_state_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c
|
||||
if (pipe_widget->instance_id < 0)
|
||||
return 0;
|
||||
|
||||
mutex_lock(&ipc4_data->pipeline_state_mutex);
|
||||
guard(mutex)(&ipc4_data->pipeline_state_mutex);
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
@@ -396,14 +396,16 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c
|
||||
ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id,
|
||||
SOF_IPC4_PIPE_PAUSED);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
pipeline->state = SOF_IPC4_PIPE_PAUSED;
|
||||
}
|
||||
|
||||
ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id,
|
||||
SOF_IPC4_PIPE_RUNNING);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
pipeline->state = SOF_IPC4_PIPE_RUNNING;
|
||||
swidget->spipe->started_count++;
|
||||
break;
|
||||
@@ -411,7 +413,8 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c
|
||||
ret = sof_ipc4_set_pipeline_state(sdev, pipe_widget->instance_id,
|
||||
SOF_IPC4_PIPE_RUNNING);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
pipeline->state = SOF_IPC4_PIPE_RUNNING;
|
||||
break;
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
@@ -429,8 +432,7 @@ static int hda_ipc4_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *c
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
out:
|
||||
mutex_unlock(&ipc4_data->pipeline_state_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -524,11 +524,8 @@ void hdac_bus_eml_enable_interrupt(struct hdac_bus *bus, bool alt, int elid, boo
|
||||
|
||||
hlink = &h2link->hext_link;
|
||||
|
||||
mutex_lock(&h2link->eml_lock);
|
||||
|
||||
hdaml_link_enable_interrupt(hlink->ml_addr + AZX_REG_ML_LCTL, enable);
|
||||
|
||||
mutex_unlock(&h2link->eml_lock);
|
||||
scoped_guard(mutex, &h2link->eml_lock)
|
||||
hdaml_link_enable_interrupt(hlink->ml_addr + AZX_REG_ML_LCTL, enable);
|
||||
}
|
||||
EXPORT_SYMBOL_NS(hdac_bus_eml_enable_interrupt, "SND_SOC_SOF_HDA_MLINK");
|
||||
|
||||
@@ -837,11 +834,8 @@ int hdac_bus_eml_sdw_set_lsdiid(struct hdac_bus *bus, int sublink, int dev_num)
|
||||
|
||||
hlink = &h2link->hext_link;
|
||||
|
||||
mutex_lock(&h2link->eml_lock);
|
||||
|
||||
hdaml_link_set_lsdiid(hlink->ml_addr + AZX_REG_ML_LSDIID_OFFSET(sublink), dev_num);
|
||||
|
||||
mutex_unlock(&h2link->eml_lock);
|
||||
scoped_guard(mutex, &h2link->eml_lock)
|
||||
hdaml_link_set_lsdiid(hlink->ml_addr + AZX_REG_ML_LSDIID_OFFSET(sublink), dev_num);
|
||||
|
||||
return 0;
|
||||
} EXPORT_SYMBOL_NS(hdac_bus_eml_sdw_set_lsdiid, "SND_SOC_SOF_HDA_MLINK");
|
||||
@@ -875,12 +869,8 @@ int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y,
|
||||
lchan = 0;
|
||||
}
|
||||
|
||||
mutex_lock(&h2link->eml_lock);
|
||||
|
||||
hdaml_shim_map_stream_ch(pcmsycm, lchan, hchan,
|
||||
stream_id, dir);
|
||||
|
||||
mutex_unlock(&h2link->eml_lock);
|
||||
scoped_guard(mutex, &h2link->eml_lock)
|
||||
hdaml_shim_map_stream_ch(pcmsycm, lchan, hchan, stream_id, dir);
|
||||
|
||||
val = readw(pcmsycm);
|
||||
|
||||
@@ -1012,11 +1002,8 @@ int hdac_bus_eml_enable_offload(struct hdac_bus *bus, bool alt, int elid, bool e
|
||||
|
||||
hlink = &h2link->hext_link;
|
||||
|
||||
mutex_lock(&h2link->eml_lock);
|
||||
|
||||
hdaml_lctl_offload_enable(hlink->ml_addr + AZX_REG_ML_LCTL, enable);
|
||||
|
||||
mutex_unlock(&h2link->eml_lock);
|
||||
scoped_guard(mutex, &h2link->eml_lock)
|
||||
hdaml_lctl_offload_enable(hlink->ml_addr + AZX_REG_ML_LCTL, enable);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user