mirror of
https://github.com/torvalds/linux.git
synced 2026-07-30 19:21:28 +02:00
ASoC: ti: omap-dmic: Use guard() for mutex locks
Replace open-coded mutex_lock()/mutex_unlock() pairs with guard(mutex)() and scoped_guard() helpers. This also simplifies the control flow by removing temporary return variables and unnecessary goto-based cleanup paths. No functional change intended. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Link: https://patch.msgid.link/20260508103837.138142-3-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
6f4cf77320
commit
bc59728f93
|
|
@ -91,18 +91,14 @@ static int omap_dmic_dai_startup(struct snd_pcm_substream *substream,
|
|||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&dmic->mutex);
|
||||
guard(mutex)(&dmic->mutex);
|
||||
|
||||
if (!snd_soc_dai_active(dai))
|
||||
dmic->active = 1;
|
||||
else
|
||||
ret = -EBUSY;
|
||||
if (snd_soc_dai_active(dai))
|
||||
return -EBUSY;
|
||||
|
||||
mutex_unlock(&dmic->mutex);
|
||||
|
||||
return ret;
|
||||
dmic->active = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void omap_dmic_dai_shutdown(struct snd_pcm_substream *substream,
|
||||
|
|
@ -110,14 +106,12 @@ static void omap_dmic_dai_shutdown(struct snd_pcm_substream *substream,
|
|||
{
|
||||
struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);
|
||||
|
||||
mutex_lock(&dmic->mutex);
|
||||
guard(mutex)(&dmic->mutex);
|
||||
|
||||
cpu_latency_qos_remove_request(&dmic->pm_qos_req);
|
||||
|
||||
if (!snd_soc_dai_active(dai))
|
||||
dmic->active = 0;
|
||||
|
||||
mutex_unlock(&dmic->mutex);
|
||||
}
|
||||
|
||||
static int omap_dmic_select_divider(struct omap_dmic *dmic, int sample_rate)
|
||||
|
|
@ -334,26 +328,24 @@ static int omap_dmic_select_fclk(struct omap_dmic *dmic, int clk_id,
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
mutex_lock(&dmic->mutex);
|
||||
if (dmic->active) {
|
||||
/* disable clock while reparenting */
|
||||
pm_runtime_put_sync(dmic->dev);
|
||||
ret = clk_set_parent(mux, parent_clk);
|
||||
pm_runtime_get_sync(dmic->dev);
|
||||
} else {
|
||||
ret = clk_set_parent(mux, parent_clk);
|
||||
scoped_guard(mutex, &dmic->mutex) {
|
||||
if (dmic->active) {
|
||||
/* disable clock while reparenting */
|
||||
pm_runtime_put_sync(dmic->dev);
|
||||
ret = clk_set_parent(mux, parent_clk);
|
||||
pm_runtime_get_sync(dmic->dev);
|
||||
} else {
|
||||
ret = clk_set_parent(mux, parent_clk);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&dmic->mutex);
|
||||
|
||||
if (ret < 0) {
|
||||
dev_err(dmic->dev, "re-parent failed\n");
|
||||
goto err_busy;
|
||||
} else {
|
||||
dmic->sysclk = clk_id;
|
||||
dmic->fclk_freq = freq;
|
||||
}
|
||||
|
||||
dmic->sysclk = clk_id;
|
||||
dmic->fclk_freq = freq;
|
||||
|
||||
err_busy:
|
||||
clk_put(mux);
|
||||
clk_put(parent_clk);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user