Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: ak4458 & ak5558: disable regulator if error
@ 2025-12-02  8:35 Shengjiu Wang
  2025-12-02  8:35 ` [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens Shengjiu Wang
  2025-12-02  8:35 ` [PATCH 2/2] ASoC: ak5558: " Shengjiu Wang
  0 siblings, 2 replies; 6+ messages in thread
From: Shengjiu Wang @ 2025-12-02  8:35 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, andriy.shevchenko,
	kuninori.morimoto.gx, nichen, linux-sound, linux-kernel, ckeepax

Disable regulator when error happens to balance the reference count.

Shengjiu Wang (2):
  ASoC: ak4458: Disable regulator when error happens
  ASoC: ak5558: Disable regulator when error happens

 sound/soc/codecs/ak4458.c | 9 ++++++++-
 sound/soc/codecs/ak5558.c | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

-- 
2.34.1


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

* [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens
  2025-12-02  8:35 [PATCH 0/2] ASoC: ak4458 & ak5558: disable regulator if error Shengjiu Wang
@ 2025-12-02  8:35 ` Shengjiu Wang
  2025-12-02 13:37   ` Mark Brown
  2025-12-02 14:13   ` Andy Shevchenko
  2025-12-02  8:35 ` [PATCH 2/2] ASoC: ak5558: " Shengjiu Wang
  1 sibling, 2 replies; 6+ messages in thread
From: Shengjiu Wang @ 2025-12-02  8:35 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, andriy.shevchenko,
	kuninori.morimoto.gx, nichen, linux-sound, linux-kernel, ckeepax

Disable regulator in runtime resume when error happens to balance
the reference count of regulator.

Fixes: 7e3096e8f823 ("ASoC: ak4458: Add regulator support")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/codecs/ak4458.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c
index 893071d7a57f..dab38d1cbaca 100644
--- a/sound/soc/codecs/ak4458.c
+++ b/sound/soc/codecs/ak4458.c
@@ -671,7 +671,14 @@ static int ak4458_runtime_resume(struct device *dev)
 	regcache_cache_only(ak4458->regmap, false);
 	regcache_mark_dirty(ak4458->regmap);
 
-	return regcache_sync(ak4458->regmap);
+	ret = regcache_sync(ak4458->regmap);
+	if (ret)
+		goto err;
+
+	return 0;
+err:
+	regulator_bulk_disable(ARRAY_SIZE(ak4458->supplies), ak4458->supplies);
+	return ret;
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_ak4458 = {
-- 
2.34.1


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

* [PATCH 2/2] ASoC: ak5558: Disable regulator when error happens
  2025-12-02  8:35 [PATCH 0/2] ASoC: ak4458 & ak5558: disable regulator if error Shengjiu Wang
  2025-12-02  8:35 ` [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens Shengjiu Wang
@ 2025-12-02  8:35 ` Shengjiu Wang
  1 sibling, 0 replies; 6+ messages in thread
From: Shengjiu Wang @ 2025-12-02  8:35 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, andriy.shevchenko,
	kuninori.morimoto.gx, nichen, linux-sound, linux-kernel, ckeepax

Disable regulator in runtime resume when error happens to balance
the reference count of regulator.

Fixes: 2ff6d5a108c6 ("ASoC: ak5558: Add regulator support")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/codecs/ak5558.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c
index 683f3e472f50..69ec215e2817 100644
--- a/sound/soc/codecs/ak5558.c
+++ b/sound/soc/codecs/ak5558.c
@@ -372,7 +372,14 @@ static int ak5558_runtime_resume(struct device *dev)
 	regcache_cache_only(ak5558->regmap, false);
 	regcache_mark_dirty(ak5558->regmap);
 
-	return regcache_sync(ak5558->regmap);
+	ret = regcache_sync(ak5558->regmap);
+	if (ret)
+		goto err;
+
+	return 0;
+err:
+	regulator_bulk_disable(ARRAY_SIZE(ak5558->supplies), ak5558->supplies);
+	return ret;
 }
 
 static const struct dev_pm_ops ak5558_pm = {
-- 
2.34.1


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

* Re: [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens
  2025-12-02  8:35 ` [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens Shengjiu Wang
@ 2025-12-02 13:37   ` Mark Brown
  2025-12-03  6:09     ` Shengjiu Wang
  2025-12-02 14:13   ` Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2025-12-02 13:37 UTC (permalink / raw)
  To: Shengjiu Wang
  Cc: lgirdwood, perex, tiwai, andriy.shevchenko, kuninori.morimoto.gx,
	nichen, linux-sound, linux-kernel, ckeepax

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

On Tue, Dec 02, 2025 at 04:35:34PM +0800, Shengjiu Wang wrote:

> --- a/sound/soc/codecs/ak4458.c
> +++ b/sound/soc/codecs/ak4458.c
> @@ -671,7 +671,14 @@ static int ak4458_runtime_resume(struct device *dev)
>  	regcache_cache_only(ak4458->regmap, false);
>  	regcache_mark_dirty(ak4458->regmap);
>  
> -	return regcache_sync(ak4458->regmap);
> +	ret = regcache_sync(ak4458->regmap);
> +	if (ret)
> +		goto err;
> +
> +	return 0;
> +err:
> +	regulator_bulk_disable(ARRAY_SIZE(ak4458->supplies), ak4458->supplies);
> +	return ret;

While we're at it we should also put the regmap back into cache only
mode, not that the error is likely to be usefully recoverable.

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

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

* Re: [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens
  2025-12-02  8:35 ` [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens Shengjiu Wang
  2025-12-02 13:37   ` Mark Brown
@ 2025-12-02 14:13   ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-12-02 14:13 UTC (permalink / raw)
  To: Shengjiu Wang
  Cc: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx, nichen,
	linux-sound, linux-kernel, ckeepax

On Tue, Dec 02, 2025 at 04:35:34PM +0800, Shengjiu Wang wrote:
> Disable regulator in runtime resume when error happens to balance
> the reference count of regulator.

...

> -	return regcache_sync(ak4458->regmap);
> +	ret = regcache_sync(ak4458->regmap);
> +	if (ret)
> +		goto err;
> +
> +	return 0;
> +err:
> +	regulator_bulk_disable(ARRAY_SIZE(ak4458->supplies), ak4458->supplies);
> +	return ret;

	ret = regcache_sync(ak4458->regmap);
	if (ret)
		regulator_bulk_disable(ARRAY_SIZE(ak4458->supplies), ak4458->supplies);

	return ret;

is also okay in this case.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens
  2025-12-02 13:37   ` Mark Brown
@ 2025-12-03  6:09     ` Shengjiu Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Shengjiu Wang @ 2025-12-03  6:09 UTC (permalink / raw)
  To: Mark Brown
  Cc: Shengjiu Wang, lgirdwood, perex, tiwai, andriy.shevchenko,
	kuninori.morimoto.gx, nichen, linux-sound, linux-kernel, ckeepax

On Tue, Dec 2, 2025 at 9:38 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Tue, Dec 02, 2025 at 04:35:34PM +0800, Shengjiu Wang wrote:
>
> > --- a/sound/soc/codecs/ak4458.c
> > +++ b/sound/soc/codecs/ak4458.c
> > @@ -671,7 +671,14 @@ static int ak4458_runtime_resume(struct device *dev)
> >       regcache_cache_only(ak4458->regmap, false);
> >       regcache_mark_dirty(ak4458->regmap);
> >
> > -     return regcache_sync(ak4458->regmap);
> > +     ret = regcache_sync(ak4458->regmap);
> > +     if (ret)
> > +             goto err;
> > +
> > +     return 0;
> > +err:
> > +     regulator_bulk_disable(ARRAY_SIZE(ak4458->supplies), ak4458->supplies);
> > +     return ret;
>
> While we're at it we should also put the regmap back into cache only
> mode, not that the error is likely to be usefully recoverable.

Thanks, I will update it.

Best regards
Shengjiu Wang

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

end of thread, other threads:[~2025-12-03  6:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02  8:35 [PATCH 0/2] ASoC: ak4458 & ak5558: disable regulator if error Shengjiu Wang
2025-12-02  8:35 ` [PATCH 1/2] ASoC: ak4458: Disable regulator when error happens Shengjiu Wang
2025-12-02 13:37   ` Mark Brown
2025-12-03  6:09     ` Shengjiu Wang
2025-12-02 14:13   ` Andy Shevchenko
2025-12-02  8:35 ` [PATCH 2/2] ASoC: ak5558: " Shengjiu Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox