linux-sound.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: codecs: ES8389: Prevent enable_count underflow in clk_core_disable
@ 2026-09-04 10:41 Zhang Yi
  2026-09-04 16:53 ` Mark Brown
  2026-09-08  9:11 ` Diederik de Haas
  0 siblings, 2 replies; 3+ messages in thread
From: Zhang Yi @ 2026-09-04 10:41 UTC (permalink / raw)
  To: linux-sound, broonie; +Cc: tiwai, Zhang Yi

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.

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;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: codecs: ES8389: Prevent enable_count underflow in clk_core_disable
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-09-04 16:53 UTC (permalink / raw)
  To: linux-sound, Zhang Yi; +Cc: tiwai

On Fri, 04 Sep 2026 18:41:41 +0800, Zhang Yi wrote:
> ASoC: codecs: ES8389: Prevent enable_count underflow in clk_core_disable

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3

Thanks!

[1/1] ASoC: codecs: ES8389: Prevent enable_count underflow in clk_core_disable
      https://git.kernel.org/broonie/sound/c/c1e01ea35093

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: codecs: ES8389: Prevent enable_count underflow in clk_core_disable
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Diederik de Haas @ 2026-09-08  9:11 UTC (permalink / raw)
  To: linux-sound, broonie; +Cc: tiwai

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;
>  }



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-08  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).