diff options
| author | Peter Ujfalusi <peter.ujfalusi@linux.intel.com> | 2026-01-12 12:09:58 +0200 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-01-12 11:21:24 +0000 |
| commit | 5c19da34df029fdc29fec1bedf210af7d2c4fccf (patch) | |
| tree | cd2ac49beabeaba9521426052546a528066c6b9f /sound/soc/sof/sof-audio.c | |
| parent | 0cd9bf6a6d9a1861087236cc5c275b3bea83cfdd (diff) | |
ASoC: SOF: 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-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/sof-audio.c')
| -rw-r--r-- | sound/soc/sof/sof-audio.c | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index a9664b4cf43f..d55ee7343f8e 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -121,13 +121,8 @@ static int sof_widget_free_unlocked(struct snd_sof_dev *sdev, int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) { - int ret; - - mutex_lock(&swidget->setup_mutex); - ret = sof_widget_free_unlocked(sdev, swidget); - mutex_unlock(&swidget->setup_mutex); - - return ret; + guard(mutex)(&swidget->setup_mutex); + return sof_widget_free_unlocked(sdev, swidget); } EXPORT_SYMBOL(sof_widget_free); @@ -240,13 +235,8 @@ use_count_dec: int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) { - int ret; - - mutex_lock(&swidget->setup_mutex); - ret = sof_widget_setup_unlocked(sdev, swidget); - mutex_unlock(&swidget->setup_mutex); - - return ret; + guard(mutex)(&swidget->setup_mutex); + return sof_widget_setup_unlocked(sdev, swidget); } EXPORT_SYMBOL(sof_widget_setup); @@ -377,24 +367,22 @@ static int sof_setup_pipeline_connections(struct snd_sof_dev *sdev, else swidget = sroute->src_widget; - mutex_lock(&swidget->setup_mutex); - if (!swidget->use_count) { - mutex_unlock(&swidget->setup_mutex); - continue; - } + scoped_guard(mutex, &swidget->setup_mutex) { + if (!swidget->use_count) + continue; - if (tplg_ops && tplg_ops->route_setup) { - /* - * this route will get freed when either the source widget or the sink - * widget is freed during hw_free - */ - ret = tplg_ops->route_setup(sdev, sroute); - if (!ret) - sroute->setup = true; + if (tplg_ops && tplg_ops->route_setup) { + /* + * this route will get freed when either the + * source widget or the sink widget is freed + * during hw_free + */ + ret = tplg_ops->route_setup(sdev, sroute); + if (!ret) + sroute->setup = true; + } } - mutex_unlock(&swidget->setup_mutex); - if (ret < 0) return ret; } |
