Re: [PATCH v3] ASoC: wm8962: Stop IRQ from requeuing mic_work on remove
From: Charles Keepax
Date: Fri Sep 25 2026 - 05:09:25 EST
On Thu, Sep 24, 2026 at 03:05:41PM -0700, mhun512@xxxxxxxxx wrote:
> diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
> index 8a9598161b35..7b09de65a009 100644
> --- a/sound/soc/codecs/wm8962.c
> +++ b/sound/soc/codecs/wm8962.c
> @@ -3230,21 +3230,22 @@ int wm8962_mic_detect(struct snd_soc_component
> *component, struct snd_soc_jack *
> {
> struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
> struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
> - int irq_mask, enable;
> -
> - wm8962->jack = jack;
> - if (jack) {
> - irq_mask = 0;
> - enable = WM8962_MICDET_ENA;
> - } else {
> - irq_mask = WM8962_MICD_EINT | WM8962_MICSCD_EINT;
> - enable = 0;
> - }
> + int mic_irq_mask = WM8962_MICD_EINT | WM8962_MICSCD_EINT;
>
> + /* Mask microphone events, then drain the IRQ and work before
> changing the jack. */
Your email client appears to be corrupting the patch here, this
won't apply.
> snd_soc_component_update_bits(component, WM8962_INTERRUPT_STATUS_2_MASK,
> - WM8962_MICD_EINT | WM8962_MICSCD_EINT, irq_mask);
> + mic_irq_mask, mic_irq_mask);
> snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_4,
> - WM8962_MICDET_ENA, enable);
> + WM8962_MICDET_ENA, jack ? WM8962_MICDET_ENA : 0);
I would be tempted to just always disable here.
> + if (wm8962->irq)
> + synchronize_irq(wm8962->irq);
> + cancel_delayed_work_sync(&wm8962->mic_work);
> +
> + wm8962->jack = jack;
> + if (jack)
> + snd_soc_component_update_bits(component,
> + WM8962_INTERRUPT_STATUS_2_MASK,
> + mic_irq_mask, 0);
And then enable here, if needed. The current patch changes from
enabling after the IRQ is unmasked to enabling whilst it is
masked. Since neither of us have hardware its probably better not
to change that sequencing.
>
> /* Send an initial empty report */
> snd_soc_jack_report(wm8962->jack, 0,
> @@ -3592,9 +3593,7 @@ static int wm8962_probe(struct snd_soc_component
> *component)
>
> static void wm8962_remove(struct snd_soc_component *component)
> {
> - struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
> -
> - cancel_delayed_work_sync(&wm8962->mic_work);
> + wm8962_mic_detect(component, NULL);
>
> wm8962_free_gpio(component);
> wm8962_free_beep(component);
> diff --git a/sound/soc/tegra/tegra_wm8962.c b/sound/soc/tegra/tegra_wm8962.c
> index 31f9d9181595..a79d464b6a80 100644
> --- a/sound/soc/tegra/tegra_wm8962.c
> +++ b/sound/soc/tegra/tegra_wm8962.c
> @@ -97,18 +97,6 @@ static int tegra_wm8962_init(struct snd_soc_pcm_runtime *rtd)
> return 0;
> }
>
> -static int tegra_wm8962_remove(struct snd_soc_card *card)
> -{
> - struct snd_soc_dai_link *link = &card->dai_link[0];
> - struct snd_soc_pcm_runtime *rtd = snd_soc_get_pcm_runtime(card, link);
> - struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
> - struct snd_soc_component *component = codec_dai->component;
> -
> - wm8962_mic_detect(component, NULL);
> -
> - return 0;
> -}
I don't think you should remove this. It is possible to remove
the machine driver but not the codec driver, and in that case you
still want the mic_detect disabled.
Thanks,
Charles