public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: es8328: Propagate error codes from regmap updates
@ 2026-01-15 16:13 Hsieh Hung-En
  2026-01-16 13:22 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Hsieh Hung-En @ 2026-01-15 16:13 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel,
	Hsieh Hung-En

In es8328_hw_params(), the return value of
snd_soc_component_update_bits() was ignored. This could lead to silent
failures where the hardware is left in an inconsistent state if a
regmap write fails.

Check the return value of regmap updates and propagate any errors back
to the ALSA core. Return 0 on success to match the DAI ops convention.

Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com>
---
 sound/soc/codecs/es8328.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c
index bd74e896d602..38340f292282 100644
--- a/sound/soc/codecs/es8328.c
+++ b/sound/soc/codecs/es8328.c
@@ -461,6 +461,7 @@ static int es8328_hw_params(struct snd_pcm_substream *substream,
 {
 	struct snd_soc_component *component = dai->component;
 	struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component);
+	int ret;
 	int i;
 	int reg;
 	int wl;
@@ -494,9 +495,12 @@ static int es8328_hw_params(struct snd_pcm_substream *substream,
 		es8328->mclkdiv2 = 0;
 	}
 
-	snd_soc_component_update_bits(component, ES8328_MASTERMODE,
-			ES8328_MASTERMODE_MCLKDIV2,
-			es8328->mclkdiv2 ? ES8328_MASTERMODE_MCLKDIV2 : 0);
+	ret = snd_soc_component_update_bits(component, ES8328_MASTERMODE,
+					    ES8328_MASTERMODE_MCLKDIV2,
+					    es8328->mclkdiv2 ?
+					    ES8328_MASTERMODE_MCLKDIV2 : 0);
+	if (ret < 0)
+		return ret;
 
 	switch (params_width(params)) {
 	case 16:
@@ -519,18 +523,26 @@ static int es8328_hw_params(struct snd_pcm_substream *substream,
 	}
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		snd_soc_component_update_bits(component, ES8328_DACCONTROL1,
-				ES8328_DACCONTROL1_DACWL_MASK,
-				wl << ES8328_DACCONTROL1_DACWL_SHIFT);
+		ret = snd_soc_component_update_bits(component, ES8328_DACCONTROL1,
+						    ES8328_DACCONTROL1_DACWL_MASK,
+						    wl << ES8328_DACCONTROL1_DACWL_SHIFT);
+		if (ret < 0)
+			return ret;
 
 		es8328->playback_fs = params_rate(params);
 		es8328_set_deemph(component);
-	} else
-		snd_soc_component_update_bits(component, ES8328_ADCCONTROL4,
-				ES8328_ADCCONTROL4_ADCWL_MASK,
-				wl << ES8328_ADCCONTROL4_ADCWL_SHIFT);
+	} else {
+		ret = snd_soc_component_update_bits(component, ES8328_ADCCONTROL4,
+						    ES8328_ADCCONTROL4_ADCWL_MASK,
+						    wl << ES8328_ADCCONTROL4_ADCWL_SHIFT);
+		if (ret < 0)
+			return ret;
+	}
 
-	return snd_soc_component_update_bits(component, reg, ES8328_RATEMASK, ratio);
+	ret = snd_soc_component_update_bits(component, reg, ES8328_RATEMASK, ratio);
+	if (ret < 0)
+		return ret;
+	return 0;
 }
 
 static int es8328_set_sysclk(struct snd_soc_dai *codec_dai,
-- 
2.34.1


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

* Re: [PATCH] ASoC: es8328: Propagate error codes from regmap updates
  2026-01-15 16:13 [PATCH] ASoC: es8328: Propagate error codes from regmap updates Hsieh Hung-En
@ 2026-01-16 13:22 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-01-16 13:22 UTC (permalink / raw)
  To: Liam Girdwood, Hsieh Hung-En
  Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel

On Fri, 16 Jan 2026 00:13:59 +0800, Hsieh Hung-En wrote:
> In es8328_hw_params(), the return value of
> snd_soc_component_update_bits() was ignored. This could lead to silent
> failures where the hardware is left in an inconsistent state if a
> regmap write fails.
> 
> Check the return value of regmap updates and propagate any errors back
> to the ALSA core. Return 0 on success to match the DAI ops convention.
> 
> [...]

Applied to

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

Thanks!

[1/1] ASoC: es8328: Propagate error codes from regmap updates
      commit: 4711b292b440a8404833df0e0ba96dad86600a84

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] 2+ messages in thread

end of thread, other threads:[~2026-01-16 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 16:13 [PATCH] ASoC: es8328: Propagate error codes from regmap updates Hsieh Hung-En
2026-01-16 13:22 ` Mark Brown

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