[PATCH 04/10] ASoC: mediatek: mt8188: mt8188-afe-clk: Use guard() for spin locks
phucduc.bui at gmail.com
phucduc.bui at gmail.com
Wed Jun 10 03:20:15 PDT 2026
From: bui duc phuc <phucduc.bui at gmail.com>
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Signed-off-by: bui duc phuc <phucduc.bui at gmail.com>
---
sound/soc/mediatek/mt8188/mt8188-afe-clk.c | 29 ++++++++--------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
index 7f411b857782..fc6cb3f0469e 100644
--- a/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
+++ b/sound/soc/mediatek/mt8188/mt8188-afe-clk.c
@@ -301,7 +301,6 @@ static int mt8188_afe_disable_tuner_clk(struct mtk_base_afe *afe,
static int mt8188_afe_enable_apll_tuner(struct mtk_base_afe *afe, unsigned int id)
{
struct mt8188_afe_tuner_cfg *cfg = mt8188_afe_found_apll_tuner(id);
- unsigned long flags;
int ret;
if (!cfg)
@@ -315,8 +314,7 @@ static int mt8188_afe_enable_apll_tuner(struct mtk_base_afe *afe, unsigned int i
if (ret)
return ret;
- spin_lock_irqsave(&cfg->ctrl_lock, flags);
-
+ guard(spinlock_irqsave)(&cfg->ctrl_lock);
cfg->ref_cnt++;
if (cfg->ref_cnt == 1)
regmap_update_bits(afe->regmap,
@@ -324,32 +322,27 @@ static int mt8188_afe_enable_apll_tuner(struct mtk_base_afe *afe, unsigned int i
cfg->tuner_en_maskbit << cfg->tuner_en_shift,
BIT(cfg->tuner_en_shift));
- spin_unlock_irqrestore(&cfg->ctrl_lock, flags);
-
return 0;
}
static int mt8188_afe_disable_apll_tuner(struct mtk_base_afe *afe, unsigned int id)
{
struct mt8188_afe_tuner_cfg *cfg = mt8188_afe_found_apll_tuner(id);
- unsigned long flags;
int ret;
if (!cfg)
return -EINVAL;
- spin_lock_irqsave(&cfg->ctrl_lock, flags);
-
- cfg->ref_cnt--;
- if (cfg->ref_cnt == 0)
- regmap_update_bits(afe->regmap,
- cfg->tuner_en_reg,
- cfg->tuner_en_maskbit << cfg->tuner_en_shift,
- 0 << cfg->tuner_en_shift);
- else if (cfg->ref_cnt < 0)
- cfg->ref_cnt = 0;
-
- spin_unlock_irqrestore(&cfg->ctrl_lock, flags);
+ scoped_guard(spinlock_irqsave, &cfg->ctrl_lock) {
+ cfg->ref_cnt--;
+ if (cfg->ref_cnt == 0)
+ regmap_update_bits(afe->regmap,
+ cfg->tuner_en_reg,
+ cfg->tuner_en_maskbit << cfg->tuner_en_shift,
+ 0 << cfg->tuner_en_shift);
+ else if (cfg->ref_cnt < 0)
+ cfg->ref_cnt = 0;
+ }
ret = mt8188_afe_disable_tuner_clk(afe, id);
if (ret)
--
2.43.0
More information about the linux-arm-kernel
mailing list