Re: [PATCH v4 07/16] ASoC: mediatek: mt8365: Add ADDA DAI support

From: Alexandre Mergnat
Date: Wed May 22 2024 - 05:23:46 EST




On 20/05/2024 12:27, AngeloGioacchino Del Regno wrote:
+int mt8365_dai_disable_adda_on(struct mtk_base_afe *afe)
+{
+    unsigned long flags;
+    struct mt8365_afe_private *afe_priv = afe->platform_priv;
+
+    spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
+
+    adda_afe_on_ref_cnt--;
+    if (adda_afe_on_ref_cnt == 0)
+        regmap_update_bits(afe->regmap, AFE_ADDA_UL_DL_CON0,
+                   AFE_ADDA_UL_DL_ADDA_AFE_ON,
+                   ~AFE_ADDA_UL_DL_ADDA_AFE_ON);
+    else if (adda_afe_on_ref_cnt < 0)
+        adda_afe_on_ref_cnt = 0;

Should we dev_warn() here? The refcount should never be less than zero - if it is,
then there's some issue somewhere that must be solved.

Ok to add dev_warn, but I also want to keep "adda_afe_on_ref_cnt = 0;" for robustness, even if it shouldn't reach this case.

--
Regards,
Alexandre