mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: mhun512@gmail.com
Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, patches@opensource.cirrus.com,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, ae878000@gmail.com
Subject: Re: [PATCH v3] ASoC: wm8962: Stop IRQ from requeuing mic_work on remove
Date: Fri, 25 Sep 2026 10:08:41 +0100	[thread overview]
Message-ID: <arY6GbRBjKxJDKVn@opensource.cirrus.com> (raw)
In-Reply-To: <CAGEsz8G_s8_HRnHH8s+NvXWXV8Uz2xRDY+He9M57v_fW4H42VA@mail.gmail.com>

On Thu, Sep 24, 2026 at 03:05:41PM -0700, mhun512@gmail.com 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

  reply	other threads:[~2026-09-25  9:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 22:05 mhun512
2026-09-25  9:08 ` Charles Keepax [this message]
2026-09-25  9:31   ` Charles Keepax

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=arY6GbRBjKxJDKVn@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=ae878000@gmail.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=mhun512@gmail.com \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®