public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Zhang Yi <zhangyi@everest-semi.com>
Cc: tiwai@suse.com, linux-sound@vger.kernel.org,
	peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com,
	ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com,
	ckeepax@opensource.cirrus.com
Subject: Re: [PATCH v6 3/5] ASoC: es9356-sdca: Add ES9356 SDCA driver
Date: Thu, 9 Apr 2026 21:11:44 +0100	[thread overview]
Message-ID: <adgIAKKsEP6bSTRe@sirena.co.uk> (raw)
In-Reply-To: <20260409021255.1006-4-zhangyi@everest-semi.com>

[-- Attachment #1: Type: text/plain, Size: 1583 bytes --]

On Thu, Apr 09, 2026 at 10:12:53AM +0800, Zhang Yi wrote:
> This is the codec driver for es9356-sdca.

> +static int es9356_sdca_headset_detect(struct es9356_sdw_priv *es9356)
> +{
> +	unsigned int reg;
> +	int ret;
> +
> +	ret = regmap_read(es9356->regmap,
> +			SDW_SDCA_CTL(FUNC_NUM_UAJ, ES9356_SDCA_ENT_GE35, ES9356_SDCA_CTL_DETECTED_MODE, 0), &reg);
> +
> +	if (ret < 0)
> +		goto io_error;
> +
> +	switch (reg) {

> +	default:
> +		es9356->jack_type = -1;
> +		break;

This is going to wind up as an all bits set, meaning that whenever we
detect a button we'll end up reporting everything possible as detected.
It's probably best to either ensure we can't report anything if there's
no jack detected or figure out what would cause the hardware to produce
a bogus value and report that as a fallback (eg, go with headphone since
we know there's *something* in the jack and it's safer than headset).

> +	if (status->sdca_cascade && !es9356->disable_irq)
> +		mod_delayed_work(system_power_efficient_wq,
> +			&es9356->jack_detect_work, msecs_to_jiffies(280));
> +
> +	mutex_unlock(&es9356->jack_lock);

> +static int es9356_sdca_dev_suspend(struct device *dev)
> +{
> +	struct es9356_sdw_priv *es9356 = dev_get_drvdata(dev);
> +
> +	es9356->disable_irq = true;
> +	cancel_delayed_work_sync(&es9356->jack_detect_work);
> +	cancel_delayed_work_sync(&es9356->button_detect_work);

This doesn't hold jack_lock so we might still race with an interrupt
callback, the above code needs to take the lock to ensure a callback
doesn't reschedule the work after we thought we cancelled it.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2026-04-09 20:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09  2:12 [PATCH v6 0/5] Add es9356 focused SoundWire CODEC Zhang Yi
2026-04-09  2:12 ` [PATCH v6 1/5] ASoC: sdw_utils: add soc_sdw_es9356 Zhang Yi
2026-04-09  2:12 ` [PATCH v6 2/5] ASoC: sdw_utils: add ES9356 in codec_info_list Zhang Yi
2026-04-09  2:12 ` [PATCH v6 3/5] ASoC: es9356-sdca: Add ES9356 SDCA driver Zhang Yi
2026-04-09 10:01   ` Charles Keepax
2026-04-09 20:11   ` Mark Brown [this message]
2026-04-09  2:12 ` [PATCH v6 4/5] ASoC: Intel: soc-acpi: arl: Add es9356 support Zhang Yi
2026-04-09  2:12 ` [PATCH v6 5/5] ASoC: Intel: sof_sdw: add " Zhang Yi

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=adgIAKKsEP6bSTRe@sirena.co.uk \
    --to=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.com \
    --cc=zhangyi@everest-semi.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