]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: mediatek: mt8195: mt8195-afe-clk: Use guard() for spin locks
authorbui duc phuc <phucduc.bui@gmail.com>
Wed, 10 Jun 2026 10:20:17 +0000 (17:20 +0700)
committerMark Brown <broonie@kernel.org>
Thu, 11 Jun 2026 19:59:17 +0000 (20:59 +0100)
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
Link: https://patch.msgid.link/20260610102021.83273-7-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/mediatek/mt8195/mt8195-afe-clk.c

index f35318ae07392787ae9c540bf6c1a96818449ca3..618d8400913a33bd349ea1cf9ba57f877bec92e5 100644 (file)
@@ -283,7 +283,6 @@ static int mt8195_afe_enable_apll_tuner(struct mtk_base_afe *afe,
                                        unsigned int id)
 {
        struct mt8195_afe_tuner_cfg *cfg = mt8195_afe_found_apll_tuner(id);
-       unsigned long flags;
        int ret;
 
        if (!cfg)
@@ -297,16 +296,14 @@ static int mt8195_afe_enable_apll_tuner(struct mtk_base_afe *afe,
        if (ret)
                return ret;
 
-       spin_lock_irqsave(&cfg->ctrl_lock, flags);
-
-       cfg->ref_cnt++;
-       if (cfg->ref_cnt == 1)
-               regmap_update_bits(afe->regmap,
-                                  cfg->tuner_en_reg,
-                                  cfg->tuner_en_maskbit << cfg->tuner_en_shift,
-                                  1 << cfg->tuner_en_shift);
-
-       spin_unlock_irqrestore(&cfg->ctrl_lock, flags);
+       scoped_guard(spinlock_irqsave, &cfg->ctrl_lock) {
+               cfg->ref_cnt++;
+               if (cfg->ref_cnt == 1)
+                       regmap_update_bits(afe->regmap,
+                                          cfg->tuner_en_reg,
+                                          cfg->tuner_en_maskbit << cfg->tuner_en_shift,
+                                          1 << cfg->tuner_en_shift);
+       }
 
        return 0;
 }
@@ -315,24 +312,21 @@ static int mt8195_afe_disable_apll_tuner(struct mtk_base_afe *afe,
                                         unsigned int id)
 {
        struct mt8195_afe_tuner_cfg *cfg = mt8195_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 = mt8195_afe_disable_tuner_clk(afe, id);
        if (ret)