ASoC: codecs: cros_ec_codec: Use guard() for mutex locks

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

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Link: https://patch.msgid.link/20260708125002.202515-12-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
bui duc phuc 2026-07-08 19:49:48 +07:00 committed by Mark Brown
parent 49204ed803
commit 35150d26cb
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -12,6 +12,7 @@
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/cleanup.h>
#include <linux/io.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
@ -608,10 +609,10 @@ static void wov_copy_work(struct work_struct *w)
container_of(w, struct cros_ec_codec_priv, wov_copy_work.work);
int ret;
mutex_lock(&priv->wov_dma_lock);
guard(mutex)(&priv->wov_dma_lock);
if (!priv->wov_substream) {
dev_warn(priv->dev, "no pcm substream\n");
goto leave;
return;
}
if (ec_codec_capable(priv, EC_CODEC_CAP_WOV_AUDIO_SHM))
@ -624,8 +625,6 @@ static void wov_copy_work(struct work_struct *w)
msecs_to_jiffies(10));
else if (ret)
dev_err(priv->dev, "failed to read audio data\n");
leave:
mutex_unlock(&priv->wov_dma_lock);
}
static int wov_enable_get(struct snd_kcontrol *kcontrol,
@ -895,12 +894,11 @@ static int wov_pcm_hw_params(struct snd_soc_component *component,
struct cros_ec_codec_priv *priv =
snd_soc_component_get_drvdata(component);
mutex_lock(&priv->wov_dma_lock);
guard(mutex)(&priv->wov_dma_lock);
priv->wov_substream = substream;
priv->wov_rp = priv->wov_wp = 0;
priv->wov_dma_offset = 0;
priv->wov_burst_read = true;
mutex_unlock(&priv->wov_dma_lock);
return 0;
}
@ -911,10 +909,10 @@ static int wov_pcm_hw_free(struct snd_soc_component *component,
struct cros_ec_codec_priv *priv =
snd_soc_component_get_drvdata(component);
mutex_lock(&priv->wov_dma_lock);
wov_queue_dequeue(priv, wov_queue_size(priv));
priv->wov_substream = NULL;
mutex_unlock(&priv->wov_dma_lock);
scoped_guard(mutex, &priv->wov_dma_lock) {
wov_queue_dequeue(priv, wov_queue_size(priv));
priv->wov_substream = NULL;
}
cancel_delayed_work_sync(&priv->wov_copy_work);