Devicetree
 help / color / mirror / Atom feed
From: Shawn Guo <shengchao.guo@oss.qualcomm.com>
To: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
Cc: "Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Shenghao Ding" <shenghao-ding@ti.com>,
	"Kevin Lu" <kevin-lu@ti.com>, "Baojun Xu" <baojun.xu@ti.com>,
	"Sen Wang" <sen@ti.com>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Srinivas Kandagatla" <srini@kernel.org>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v1 1/5] ASoC: codec: adau1977-i2c: Add OF device match table
Date: Wed, 9 Sep 2026 22:44:57 +0800	[thread overview]
Message-ID: <aqFw6RNBZrkiAg-y@QCOM-aGQu4IUr3Y> (raw)
In-Reply-To: <20260907-nord-asoc-driver-support-v1-1-997d3b20cf43@oss.qualcomm.com>

On Mon, Sep 07, 2026 at 11:39:42PM +0530, Mohammad Rafi Shaik wrote:
> The ADAU1977 I2C driver lacks an OF device match table, preventing
> it from binding to codec instances described via Device Tree. Systems
> using compatible strings such as "adi,adau1977", "adi,adau1978", or
> "adi,adau1979" fail to probe the driver as a result.

This justification isn't accurate -- DT instances do bind today. The I2C
core matches DT clients by stripping the vendor prefix from the first
compatible and comparing the result against the driver's id_table:

  of_i2c_get_board_info()          drivers/i2c/i2c-core-of.c
    of_alias_from_compatible()  ->  client->name = "adau1979"
  i2c_device_match()               drivers/i2c/i2c-core-base.c
    i2c_match_id(driver->id_table, client)  -> matches

So "adi,adau1979" already probes without this patch, and the patch as
written doesn't fix a probe failure.

What it does fix -- and what I think the changelog should say -- is
module autoloading. For any client with an of_node, the bus emits the
OF modalias, not the I2C one:

  static int i2c_device_uevent(...)
  {
          rc = of_device_uevent_modalias(dev, env);
          if (rc != -ENODEV)
                  return rc;
          ...
          return add_uevent_var(env, "MODALIAS=%s%s", I2C_MODULE_PREFIX,
                                client->name);
  }

The kernel therefore advertises "of:N...Cadi,adau1979", which no module
claims without MODULE_DEVICE_TABLE(of, ...). With SND_SOC_ADAU1977_I2C=m
the codec module never gets loaded and the card stays in -EPROBE_DEFER
with nothing in the log pointing at the cause.

> 
> Add a descriptive prompt string for SND_SOC_ADAU1977_I2C/SPI so
> the driver is visible and selectable when running menuconfig.

This should probably be a separate change?

> 
> Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
> ---
>  sound/soc/codecs/Kconfig        | 4 ++--
>  sound/soc/codecs/adau1977-i2c.c | 9 +++++++++
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
> index d3730c4da51b..6f481a54313f 100644
> --- a/sound/soc/codecs/Kconfig
> +++ b/sound/soc/codecs/Kconfig
> @@ -526,13 +526,13 @@ config SND_SOC_ADAU1977
>  	tristate
>  
>  config SND_SOC_ADAU1977_SPI
> -	tristate
> +	tristate "Analog Devices ADAU1977 CODEC - SPI"
>  	depends on SPI_MASTER
>  	select SND_SOC_ADAU1977
>  	select REGMAP_SPI
>  
>  config SND_SOC_ADAU1977_I2C
> -	tristate
> +	tristate "Analog Devices ADAU1977 CODEC - I2C"
>  	depends on I2C
>  	select SND_SOC_ADAU1977
>  	select REGMAP_I2C
> diff --git a/sound/soc/codecs/adau1977-i2c.c b/sound/soc/codecs/adau1977-i2c.c
> index d1c6c4ddf506..9f54fa8375b1 100644
> --- a/sound/soc/codecs/adau1977-i2c.c
> +++ b/sound/soc/codecs/adau1977-i2c.c
> @@ -34,9 +34,18 @@ static const struct i2c_device_id adau1977_i2c_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(i2c, adau1977_i2c_ids);
>  
> +static const struct of_device_id adau1977_i2c_of_match[] __maybe_unused = {
> +	{ .compatible = "adi,adau1977" },
> +	{ .compatible = "adi,adau1978" },
> +	{ .compatible = "adi,adau1979" },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, adau1977_i2c_of_match);

Worth noting for whoever touches this next: the variant is still resolved
via i2c_get_match_data()'s fallback to id_table, since ADAU1977 == 0
can't be expressed through .data. That's fine as-is, but it means
adau1977_i2c_ids[] is now load-bearing in a way that isn't obvious --
removing it as "redundant" would silently make every compatible probe as
ADAU1977.

> +
>  static struct i2c_driver adau1977_i2c_driver = {
>  	.driver = {
>  		.name = "adau1977",
> +		.of_match_table = of_match_ptr(adau1977_i2c_of_match),

Drop of_match_ptr() and the __maybe_unused. Upstream has been removing
of_match_ptr() from drivers for years.

Shawn

>  	},
>  	.probe = adau1977_i2c_probe,
>  	.id_table = adau1977_i2c_ids,
> 
> -- 
> 2.34.1
> 
> 

  parent reply	other threads:[~2026-09-09 14:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 18:09 [PATCH 0/5] ASoC: qcom: Add Nord Ride audio support Mohammad Rafi Shaik
2026-09-07 18:09 ` [PATCH v1 1/5] ASoC: codec: adau1977-i2c: Add OF device match table Mohammad Rafi Shaik
2026-09-07 18:20   ` sashiko-bot
2026-09-09 14:44   ` Shawn Guo [this message]
2026-09-07 18:09 ` [PATCH v1 2/5] ASoC: dt-bindings: ti,pcm1681: Document the optional SCK clock Mohammad Rafi Shaik
2026-09-09 14:50   ` Shawn Guo
2026-09-07 18:09 ` [PATCH v1 3/5] ASoC: codec: pcm1681: Enable system clock before regmap access Mohammad Rafi Shaik
2026-09-07 18:17   ` sashiko-bot
2026-09-08 17:26   ` Mark Brown
2026-09-09 12:36     ` Mohammad Rafi Shaik
2026-09-09 12:39       ` Mark Brown
2026-09-09 12:45         ` Mohammad Rafi Shaik
2026-09-09 14:59   ` Shawn Guo
2026-09-07 18:09 ` [PATCH v1 4/5] ASoC: dt-bindings: qcom,sm8250: Add Nord Ride sound card Mohammad Rafi Shaik
2026-09-07 18:20   ` sashiko-bot
2026-09-09 14:54   ` Shawn Guo
2026-09-07 18:09 ` [PATCH v1 5/5] ASoC: qcom: sc8280xp: Add Nord Ride sound card support Mohammad Rafi Shaik
2026-09-09 15:37   ` Shawn Guo
2026-09-09 14:46 ` [PATCH 0/5] ASoC: qcom: Add Nord Ride audio support Shawn Guo

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=aqFw6RNBZrkiAg-y@QCOM-aGQu4IUr3Y \
    --to=shengchao.guo@oss.qualcomm.com \
    --cc=baojun.xu@ti.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kevin-lu@ti.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=mohammad.rafi.shaik@oss.qualcomm.com \
    --cc=nuno.sa@analog.com \
    --cc=perex@perex.cz \
    --cc=robh@kernel.org \
    --cc=sen@ti.com \
    --cc=shenghao-ding@ti.com \
    --cc=srini@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