]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: es8328: Propagate error codes from regmap updates
authorHsieh Hung-En <hungen3108@gmail.com>
Thu, 15 Jan 2026 16:13:59 +0000 (00:13 +0800)
committerMark Brown <broonie@kernel.org>
Thu, 15 Jan 2026 18:58:22 +0000 (18:58 +0000)
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>
Link: https://patch.msgid.link/20260115161359.41979-1-hungen3108@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/es8328.c

index bd74e896d60259d724fe5c2b3fd9d49b8baa4d47..38340f2922826bc93f09e81d1a075da047857840 100644 (file)
@@ -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,