[PATCH 3/4] ASoC: codecs: tfa989x: Handle hw_params return value
From: phucduc . bui
Date: Fri Oct 23 2026 - 05:08:50 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
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.
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/codecs/tfa989x.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c
index 7204be155eb9..885b3ea19c2c 100644
--- a/sound/soc/codecs/tfa989x.c
+++ b/sound/soc/codecs/tfa989x.c
@@ -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 = {
--
2.43.0