Skip to contentSkip to conversation

ASoC: codecs: Fix hw_params return values

PATCH In review [email protected] 3 participants 8 messages Oct 23 – Nov 2

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ASoC: codecs: Fix hw_params return values

From: bui duc phuc <[email protected]>

Hi all,

These patches ensure that the codec drivers return 0 on successful .hw_params() callbacks and propagate negative errors.

Compile-tested only.

Best regards,
Phuc

bui duc phuc (4):
ASoC: codec: cs4341: Handle hw_params return value
ASoC: codecs: si476x: Handle hw_params return value
ASoC: codecs: tfa989x: Handle hw_params return value
ASoC: codecs: wm8994: Handle hw_params return value

 sound/soc/codecs/cs4341.c  | 14 ++++++++++++--
 sound/soc/codecs/si476x.c  |  6 ++++++
 sound/soc/codecs/tfa989x.c | 17 +++++++++++++----
 sound/soc/codecs/wm8994.c  | 12 +++++++++++-
 4 files changed, 42 insertions(+), 7 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 ASoC: codec: cs4341: Handle hw_params return value

From: bui duc phuc <[email protected]>

snd_soc_component_update_bits() may return 1 when the register value changes, but ASoC only marks the DAI hw_params as done when .hw_params() returns 0.

Propagate negative errors and return 0 on success.

---
 sound/soc/codecs/cs4341.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
sound/soc/codecs/cs4341.c +12 -2
index 74544c58a415..be0ab0b128cd 100644
@@ -83,6 +83,7 @@ static int cs4341_hw_params(struct snd_pcm_substream *substream,
 	struct cs4341_priv *cs4341 = snd_soc_component_get_drvdata(component);
 	unsigned int mode = 0;
 	int b24 = 0;
+	int ret;
 
 	switch (params_format(params)) {
 	case SNDRV_PCM_FORMAT_S24_LE:
@@ -112,8 +113,17 @@ static int cs4341_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	return snd_soc_component_update_bits(component, CS4341_REG_MODE2,
-					     CS4341_MODE2_DIF, mode);
+	ret = snd_soc_component_update_bits(component, CS4341_REG_MODE2,
+					    CS4341_MODE2_DIF, mode);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * ASoC only marks the DAI hw_params as done when .hw_params() returns 0.
+	 * Since snd_soc_component_update_bits() may return 1, explicitly
+	 * return 0 to ensure the DAI is correctly marked.
+	 */
+	return 0;
 }
 
 static int cs4341_mute(struct snd_soc_dai *dai, int mute, int direction)
Signature · 1 line
2.43.0
#3 lore raw

PATCH 2/4 ASoC: codecs: si476x: Handle hw_params return value

In reply to [email protected]

From: bui duc phuc <[email protected]>

snd_soc_component_update_bits() may return 1 when the register value changes, but ASoC only marks the DAI hw_params as done when .hw_params() returns 0.

Propagate negative errors and return 0 on success.

---
 sound/soc/codecs/si476x.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/soc/codecs/si476x.c +6 -0
index 9b904450ab8a..1738377d7d7c 100644
@@ -193,6 +193,12 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
 		goto out;
 	}
 
+	/*
+	 * ASoC only marks the DAI hw_params as done when .hw_params() returns 0.
+	 * Since snd_soc_component_update_bits() may return 1, explicitly
+	 * return 0 to ensure the DAI is correctly marked.
+	 */
+	err = 0;
 out:
 	si476x_core_unlock(core);
 
Signature · 1 line
2.43.0
#4 lore raw

PATCH 3/4 ASoC: codecs: tfa989x: Handle hw_params return value

In reply to [email protected]

From: bui duc phuc <[email protected]>

snd_soc_component_update_bits() may return 1 when the register value changes, but ASoC only marks the DAI hw_params as done when .hw_params() returns 0.

Propagate negative errors and return 0 on success.

---
 sound/soc/codecs/tfa989x.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
sound/soc/codecs/tfa989x.c +13 -4
index 7204be155eb9..885b3ea19c2c 100644
@@ -160,15 +160,24 @@ static int tfa989x_hw_params(struct snd_pcm_substream *substream,
 			     struct snd_soc_dai *dai)
 {
 	struct snd_soc_component *component = dai->component;
-	int sr;
+	int sr, ret;
 
 	sr = tfa989x_find_sample_rate(params_rate(params));
 	if (sr < 0)
 		return sr;
 
-	return snd_soc_component_update_bits(component, TFA989X_I2SREG,
-					     TFA989X_I2SREG_I2SSR_MSK,
-					     sr << TFA989X_I2SREG_I2SSR);
+	ret = snd_soc_component_update_bits(component, TFA989X_I2SREG,
+					    TFA989X_I2SREG_I2SSR_MSK,
+					    sr << TFA989X_I2SREG_I2SSR);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * ASoC only marks the DAI hw_params as done when .hw_params() returns 0.
+	 * Since snd_soc_component_update_bits() may return 1, explicitly
+	 * return 0 to ensure the DAI is correctly marked.
+	 */
+	return 0;
 }
 
 static const struct snd_soc_dai_ops tfa989x_dai_ops = {
Signature · 1 line
2.43.0
#5 lore raw

PATCH 4/4 ASoC: codecs: wm8994: Handle hw_params return value

In reply to [email protected]

From: bui duc phuc <[email protected]>

snd_soc_component_update_bits() may return 1 when the register value changes, but ASoC only marks the DAI hw_params as done when .hw_params() returns 0.

Propagate negative errors and return 0 on success.

---
 sound/soc/codecs/wm8994.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8994.c +11 -1
index c65a7769a9d2..6cda0aa4c3be 100644
@@ -3093,6 +3093,7 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream,
 	struct wm8994 *control = wm8994->wm8994;
 	int aif1_reg;
 	int aif1 = 0;
+	int ret;
 
 	switch (dai->id) {
 	case 3:
@@ -3125,7 +3126,16 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream,
 		return -EINVAL;
 	}
 
-	return snd_soc_component_update_bits(component, aif1_reg, WM8994_AIF1_WL_MASK, aif1);
+	ret = snd_soc_component_update_bits(component, aif1_reg, WM8994_AIF1_WL_MASK, aif1);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * ASoC only marks the DAI hw_params as done when .hw_params() returns 0.
+	 * Since snd_soc_component_update_bits() may return 1, explicitly
+	 * return 0 to ensure the DAI is correctly marked.
+	 */
+	return 0;
 }
 
 static int wm8994_aif_mute(struct snd_soc_dai *codec_dai, int mute,
Signature · 1 line
2.43.0
Reviewed-by on v1 4/4
#6 lore raw

Re: [PATCH 4/4] ASoC: codecs: wm8994: Handle hw_params return value

Quoted 10 lines · On Fri, Oct 23, 2026 at 04:01:57PM +0700, [email protected] wrote:

From: bui duc phuc <[email protected]>

snd_soc_component_update_bits() may return 1 when the register value changes, but ASoC only marks the DAI hw_params as done when .hw_params() returns 0.

Propagate negative errors and return 0 on success.

---

Thanks,
Charles

Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] ASoC: codec: cs4341: Handle hw_params return value

In reply to [email protected]
Quoted 10 lines · On Fri, Oct 23, 2026 at 04:01:54PM +0700, [email protected] wrote:

From: bui duc phuc <[email protected]>

snd_soc_component_update_bits() may return 1 when the register value changes, but ASoC only marks the DAI hw_params as done when .hw_params() returns 0.

Propagate negative errors and return 0 on success.

---

Thanks,
Charles

maintainer
#7 lore raw
In reply to [email protected]
Quoted 10 lines · On Fri, 23 Oct 2026 16:01:53 +0700, [email protected] wrote:

ASoC: codecs: Fix hw_params return values

From: bui duc phuc <[email protected]>

Hi all,

These patches ensure that the codec drivers return 0 on successful .hw_params() callbacks and propagate negative errors.

[...]

Applied to

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

Thanks!

[1/4] ASoC: codec: cs4341: Handle hw_params return value

      https://git.kernel.org/broonie/sound/c/b622ec286008
[2/4] ASoC: codecs: si476x: Handle hw_params return value
      https://git.kernel.org/broonie/sound/c/7b2c273dbadf
[3/4] ASoC: codecs: tfa989x: Handle hw_params return value
      https://git.kernel.org/broonie/sound/c/eddb6aa0c3b8
[4/4] ASoC: codecs: wm8994: Handle hw_params return value
      https://git.kernel.org/broonie/sound/c/d310df0fb2ab

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