Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexey Charkov" <alchark@flipper.net>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
	krzk+dt@kernel.org
Subject: Re: [PATCH 2/2] ASoC: codecs: nau8822: add support for supply regulators
Date: Thu, 14 May 2026 05:39:49 +0000	[thread overview]
Message-ID: <20260514053950.37128C2BCC6@smtp.kernel.org> (raw)
In-Reply-To: <20260513-nau8822-reg-v1-2-c532e18e92ad@flipper.net>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Regulators are enabled permanently during probe and never disabled during PM or DAPM transitions.
- [Medium] Inefficient and semantically incorrect use of optional regulators in a loop instead of the bulk API.
- [Medium] Missing hardware stabilization delay after enabling power supplies before the first I2C access.
- [Low] Missing <linux/regulator/consumer.h> header inclusion.
--

commit d49855c46afc5aae191093735a6b46a1097ad452
Author: Alexey Charkov <alchark@flipper.net>

ASoC: codecs: nau8822: add support for supply regulators

This commit adds support for requesting and enabling four power supply
regulators (VDDA, VDDB, VDDC, VDDSPK) during the I2C probe of the NAU8822
codec to ensure they are online before communication.

> diff --git a/sound/soc/codecs/nau8822.c b/sound/soc/codecs/nau8822.c
> index a11759f85eaca..c21a037e0f083 100644
> --- a/sound/soc/codecs/nau8822.c
> +++ b/sound/soc/codecs/nau8822.c
> @@ -1153,7 +1153,8 @@ static int nau8822_i2c_probe(struct i2c_client *i2c)
>  {
>  	struct device *dev = &i2c->dev;
>  	struct nau8822 *nau8822 = dev_get_platdata(dev);
> -	int ret;
> +	static const char * const regulators[] = { "vdda", "vddb", "vddc", "vddspk" };
> +	int ret, i;

Should <linux/regulator/consumer.h> be included in this file since it now
uses regulator APIs?

Relying on implicit inclusion might cause build failures if header
dependencies change in the future.

[ ... ]

> @@ -1167,6 +1168,14 @@ static int nau8822_i2c_probe(struct i2c_client *i2c)
>  		return dev_err_probe(&i2c->dev, PTR_ERR(nau8822->mclk),
>  			"Error getting mclk\n");
>  
> +	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
> +		ret = devm_regulator_get_enable_optional(dev, regulators[i]);
> +		if (ret && ret != -ENODEV)
> +			return dev_err_probe(dev, ret,
> +					     "Failed to get regulator %s\n",
> +					     regulators[i]);
> +	}
> +

Does using devm_regulator_get_enable_optional() here prevent the driver
from managing power during suspend/resume or DAPM transitions?

Since this API discards the regulator handles, the driver cannot disable
the regulators when the system suspends or when the DAPM bias level drops
to SND_SOC_BIAS_OFF.

Also, since these supplies are required for communication, could
devm_regulator_bulk_get_enable() be used instead of a loop?

The bulk API automatically substitutes dummy regulators if properties are
missing in older Device Trees, avoiding the need for manual -ENODEV
filtering. It also processes ramp-up delays in parallel, whereas this loop
forces serial waits for each regulator.

Finally, is a hardware stabilization delay needed before the first I2C
access?

While the regulator framework handles the PMIC voltage ramp-up delay, it
doesn't account for the codec's internal Power-On-Reset stabilization time.

Without a post-power-on delay (like usleep_range()), can the subsequent I2C
reset race with the codec's internal reset state machine and intermittently
fail with -EREMOTEIO?

nau8822_i2c_probe() {
    ...
    nau8822->regmap = devm_regmap_init_i2c(i2c, &nau8822_regmap_config);
    ...
    /* Reset the codec */
    ret = regmap_write(nau8822->regmap, NAU8822_REG_RESET, 0x00);
    ...
}

>  	nau8822->regmap = devm_regmap_init_i2c(i2c, &nau8822_regmap_config);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260513-nau8822-reg-v1-0-c532e18e92ad@flipper.net?part=2

      parent reply	other threads:[~2026-05-14  5:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 13:39 [PATCH 0/2] ASoC: nau8822: add support for supply regulators Alexey Charkov
2026-05-13 13:39 ` [PATCH 1/2] ASoC: dt-bindings: nau8822: Add " Alexey Charkov
2026-05-13 13:39 ` [PATCH 2/2] ASoC: codecs: nau8822: add support for " Alexey Charkov
2026-05-14  1:43   ` Mark Brown
2026-05-14  5:39   ` sashiko-bot [this message]

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=20260514053950.37128C2BCC6@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alchark@flipper.net \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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