From: "Diederik de Haas" <diederik@cknow-tech.com>
To: <linux-sound@vger.kernel.org>, <broonie@kernel.org>
Cc: <tiwai@suse.com>
Subject: Re: [PATCH] ASoC: codecs: ES8389: Prevent enable_count underflow in clk_core_disable
Date: Tue, 08 Sep 2026 11:11:50 +0200 [thread overview]
Message-ID: <DL9THMPHYI9G.4JZF02QB3950@cknow-tech.com> (raw)
In-Reply-To: <20260904104141.3885-1-zhangyi@everest-semi.com>
On Fri Sep 4, 2026 at 12:41 PM CEST, Zhang Yi wrote:
> To prevent enable_count underflow in clk_core_disable,
> I replaced the direct call to `es8389_set_bias_level(component, SND_SOC_BIAS_STANDBY);`
> in the code with a helper function.
Reported-by: Diederik de Haas <diederik@cknow-tech.com>
Closes: https://lore.kernel.org/linux-sound/DJIUWLPIHZ48.5H5T2EI2YI8D@cknow-tech.com/
Tested-by: Diederik de Haas <diederik@cknow-tech.com> # NanoPC-T6 Plus
Thanks!
> Signed-off-by: Zhang Yi <zhangyi@everest-semi.com>
> ---
> sound/soc/codecs/es8389.c | 34 ++++++++++++++++++++--------------
> 1 file changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/sound/soc/codecs/es8389.c b/sound/soc/codecs/es8389.c
> index 80efce3e0..2ea0c4052 100644
> --- a/sound/soc/codecs/es8389.c
> +++ b/sound/soc/codecs/es8389.c
> @@ -812,6 +812,23 @@ static int es8389_pcm_hw_free(struct snd_pcm_substream *substream,
> return 0;
> }
>
> +static void es8389_standby(struct snd_soc_component *component)
> +{
> + struct es8389_private *es8389 = snd_soc_component_get_drvdata(component);
> +
> + regmap_update_bits(es8389->regmap, ES8389_ADC_HPF1, 0x0f, 0x04);
> + regmap_update_bits(es8389->regmap, ES8389_ADC_HPF2, 0x0f, 0x04);
> + regmap_write(es8389->regmap, ES8389_CSM_JUMP, 0xD4);
> + usleep_range(70000, 72000);
> + regmap_write(es8389->regmap, ES8389_ANA_CTL1, 0x59);
> + regmap_write(es8389->regmap, ES8389_ADC_EN, 0x00);
> + regmap_write(es8389->regmap, ES8389_CLK_OFF1, 0x00);
> + regmap_write(es8389->regmap, ES8389_RESET, 0x3E);
> + regmap_update_bits(es8389->regmap, ES8389_DAC_INV, 0x80, 0x80);
> + usleep_range(8000, 8500);
> + regmap_update_bits(es8389->regmap, ES8389_DAC_INV, 0x80, 0x00);
> +}
> +
> static int es8389_set_bias_level(struct snd_soc_component *component,
> enum snd_soc_bias_level level)
> {
> @@ -834,18 +851,7 @@ static int es8389_set_bias_level(struct snd_soc_component *component,
> case SND_SOC_BIAS_PREPARE:
> break;
> case SND_SOC_BIAS_STANDBY:
> - regmap_update_bits(es8389->regmap, ES8389_ADC_HPF1, 0x0f, 0x04);
> - regmap_update_bits(es8389->regmap, ES8389_ADC_HPF2, 0x0f, 0x04);
> - regmap_write(es8389->regmap, ES8389_CSM_JUMP, 0xD4);
> - usleep_range(70000, 72000);
> - regmap_write(es8389->regmap, ES8389_ANA_CTL1, 0x59);
> - regmap_write(es8389->regmap, ES8389_ADC_EN, 0x00);
> - regmap_write(es8389->regmap, ES8389_CLK_OFF1, 0x00);
> - regmap_write(es8389->regmap, ES8389_RESET, 0x3E);
> - regmap_update_bits(es8389->regmap, ES8389_DAC_INV, 0x80, 0x80);
> - usleep_range(8000, 8500);
> - regmap_update_bits(es8389->regmap, ES8389_DAC_INV, 0x80, 0x00);
> -
> + es8389_standby(component);
> clk_disable_unprepare(es8389->mclk);
> break;
> case SND_SOC_BIAS_OFF:
> @@ -1015,7 +1021,7 @@ static int es8389_suspend(struct snd_soc_component *component)
> {
> struct es8389_private *es8389 = snd_soc_component_get_drvdata(component);
>
> - es8389_set_bias_level(component, SND_SOC_BIAS_STANDBY);
> + es8389_standby(component);
> regcache_cache_only(es8389->regmap, true);
> regcache_mark_dirty(es8389->regmap);
>
> @@ -1084,7 +1090,7 @@ static int es8389_probe(struct snd_soc_component *component)
>
> es8389->hpf_freq = ES8389_HPF_DEFAULT;
> es8389_init(component);
> - es8389_set_bias_level(component, SND_SOC_BIAS_STANDBY);
> + es8389_standby(component);
>
> return 0;
> }
prev parent reply other threads:[~2026-09-08 9:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 10:41 [PATCH] ASoC: codecs: ES8389: Prevent enable_count underflow in clk_core_disable Zhang Yi
2026-09-04 16:53 ` Mark Brown
2026-09-08 9:11 ` Diederik de Haas [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=DL9THMPHYI9G.4JZF02QB3950@cknow-tech.com \
--to=diederik@cknow-tech.com \
--cc=broonie@kernel.org \
--cc=linux-sound@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