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

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

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Link: https://patch.msgid.link/20260721102600.523199-13-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
bui duc phuc 2026-07-21 17:25:43 +07:00 committed by Mark Brown
parent 5dabb2549c
commit 750c61b292
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -5,6 +5,7 @@
* Copyright 2011 Maxim Integrated Products
*/
#include <linux/cleanup.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
@ -1532,15 +1533,17 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
regsave = snd_soc_component_read(component, M98095_088_CFG_LEVEL);
snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, 0);
mutex_lock(&max98095->lock);
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
m98095_eq_band(component, channel, 0, coef_set->band1);
m98095_eq_band(component, channel, 1, coef_set->band2);
m98095_eq_band(component, channel, 2, coef_set->band3);
m98095_eq_band(component, channel, 3, coef_set->band4);
m98095_eq_band(component, channel, 4, coef_set->band5);
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, 0);
mutex_unlock(&max98095->lock);
scoped_guard(mutex, &max98095->lock) {
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG,
M98095_SEG, M98095_SEG);
m98095_eq_band(component, channel, 0, coef_set->band1);
m98095_eq_band(component, channel, 1, coef_set->band2);
m98095_eq_band(component, channel, 2, coef_set->band3);
m98095_eq_band(component, channel, 3, coef_set->band4);
m98095_eq_band(component, channel, 4, coef_set->band5);
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG,
M98095_SEG, 0);
}
/* Restore the original on/off state */
snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, regsave);
@ -1683,12 +1686,14 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
regsave = snd_soc_component_read(component, M98095_088_CFG_LEVEL);
snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, 0);
mutex_lock(&max98095->lock);
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
m98095_biquad_band(component, channel, 0, coef_set->band1);
m98095_biquad_band(component, channel, 1, coef_set->band2);
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, 0);
mutex_unlock(&max98095->lock);
scoped_guard(mutex, &max98095->lock) {
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG,
M98095_SEG, M98095_SEG);
m98095_biquad_band(component, channel, 0, coef_set->band1);
m98095_biquad_band(component, channel, 1, coef_set->band2);
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG,
M98095_SEG, 0);
}
/* Restore the original on/off state */
snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, regsave);