ASoC: codecs: Fix hw_params return values
Subsystems (5)
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
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
@@ -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
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
@@ -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
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
@@ -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
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
@@ -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
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 DAIhw_paramsas done when .hw_params() returns 0.Propagate negative errors and return 0 on success.
Signed-off-by bui duc phuc <[email protected]>---
Thanks,
Charles
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 DAIhw_paramsas done when .hw_params() returns 0.Propagate negative errors and return 0 on success.
Signed-off-by bui duc phuc <[email protected]>---
Thanks,
Charles
Mark Brown
maintainerQuoted 10 lines · On Fri, 23 Oct 2026 16:01:53 +0700, [email protected] wrote:
ASoC: codecs: Fix
hw_paramsreturn valuesFrom: 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