* [PATCH 1/2] ASoC: codecs: ntp8918: Fix hw_params return values
@ 2026-10-22 10:26 phucduc.bui
2026-10-22 10:26 ` [PATCH 2/2] ASoC: codecs: ntp8835: " phucduc.bui
2026-11-02 0:24 ` [PATCH 1/2] ASoC: codecs: ntp8918: " Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: phucduc.bui @ 2026-10-22 10:26 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Kuninori Morimoto, Charles Keepax, u.kleine-koenig, Igor Prusov,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
snd_soc_component_update_bits() returns 1 when the register is
updated successfully. Treating this as an error causes
ntp8918_hw_params() to return early with a positive value, skipping
the remaining configuration.
ASoC expects .hw_params() to return 0 on success to mark the
operation as completed.
Check for negative errors and return 0 on success.
Fixes: 2bd61fff3e93 ("ASoC: codecs: Add NeoFidelity NTP8918 codec")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/ntp8918.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/ntp8918.c b/sound/soc/codecs/ntp8918.c
index eca34fafc4e6..e851cfcca7c0 100644
--- a/sound/soc/codecs/ntp8918.c
+++ b/sound/soc/codecs/ntp8918.c
@@ -233,7 +233,7 @@ static int ntp8918_hw_params(struct snd_pcm_substream *substream,
ret = snd_soc_component_update_bits(component, NTP8918_MCLK_FREQ_CTRL,
NTP8918_MCLK_FREQ_MCF, mcf);
- if (ret)
+ if (ret < 0)
return ret;
switch (ntp8918->format) {
@@ -253,8 +253,10 @@ static int ntp8918_hw_params(struct snd_pcm_substream *substream,
NTP8918_INPUT_FMT_GSA_MODE,
input_fmt);
- if (!(input_fmt & NTP8918_INPUT_FMT_GSA_MODE) || ret < 0)
+ if (ret < 0)
return ret;
+ if (!(input_fmt & NTP8918_INPUT_FMT_GSA_MODE))
+ return 0;
switch (params_width(params)) {
case 24:
@@ -276,8 +278,17 @@ static int ntp8918_hw_params(struct snd_pcm_substream *substream,
gsa_fmt_mask = NTP8918_GSA_BS_MASK |
NTP8918_GSA_RIGHT_J |
NTP8918_GSA_LSB;
- return snd_soc_component_update_bits(component, NTP8918_GSA_FMT,
- gsa_fmt_mask, gsa_fmt);
+ ret = snd_soc_component_update_bits(component, NTP8918_GSA_FMT,
+ gsa_fmt_mask, gsa_fmt);
+ 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 ntp8918_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] ASoC: codecs: ntp8835: Fix hw_params return values
2026-10-22 10:26 [PATCH 1/2] ASoC: codecs: ntp8918: Fix hw_params return values phucduc.bui
@ 2026-10-22 10:26 ` phucduc.bui
2026-11-02 0:24 ` [PATCH 1/2] ASoC: codecs: ntp8918: " Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: phucduc.bui @ 2026-10-22 10:26 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Walleij, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Kuninori Morimoto, Charles Keepax, u.kleine-koenig, Igor Prusov,
linux-sound, linux-kernel, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
snd_soc_component_update_bits() returns 1 when the register is
updated successfully. Treating this as an error causes
ntp8835_hw_params() to return early with a positive value, skipping
the remaining configuration.
ASoC expects .hw_params() to return 0 on success to mark the
operation as completed.
Check for negative errors and return 0 on success.
Fixes: dc9004ea273a ("ASoC: codecs: Add NeoFidelity NTP8835 codec")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/codecs/ntp8835.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/ntp8835.c b/sound/soc/codecs/ntp8835.c
index 39620b84e214..2be713e99eab 100644
--- a/sound/soc/codecs/ntp8835.c
+++ b/sound/soc/codecs/ntp8835.c
@@ -321,7 +321,7 @@ static int ntp8835_hw_params(struct snd_pcm_substream *substream,
ret = snd_soc_component_update_bits(component, NTP8835_MCLK_FREQ_CTRL,
NTP8835_MCLK_FREQ_MCF, mcf);
- if (ret)
+ if (ret < 0)
return ret;
switch (ntp8835->format) {
@@ -341,8 +341,10 @@ static int ntp8835_hw_params(struct snd_pcm_substream *substream,
NTP8835_INPUT_FMT_GSA_MODE,
input_fmt);
- if (!(input_fmt & NTP8835_INPUT_FMT_GSA_MODE) || ret < 0)
+ if (ret < 0)
return ret;
+ if (!(input_fmt & NTP8835_INPUT_FMT_GSA_MODE))
+ return 0;
switch (params_width(params)) {
case 24:
@@ -364,8 +366,17 @@ static int ntp8835_hw_params(struct snd_pcm_substream *substream,
gsa_fmt_mask = NTP8835_GSA_BS_MASK |
NTP8835_GSA_RIGHT_J |
NTP8835_GSA_LSB;
- return snd_soc_component_update_bits(component, NTP8835_GSA_FMT,
- gsa_fmt_mask, gsa_fmt);
+ ret = snd_soc_component_update_bits(component, NTP8835_GSA_FMT,
+ gsa_fmt_mask, gsa_fmt);
+ 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 ntp8835_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] ASoC: codecs: ntp8918: Fix hw_params return values
2026-10-22 10:26 [PATCH 1/2] ASoC: codecs: ntp8918: Fix hw_params return values phucduc.bui
2026-10-22 10:26 ` [PATCH 2/2] ASoC: codecs: ntp8835: " phucduc.bui
@ 2026-11-02 0:24 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-11-02 0:24 UTC (permalink / raw)
To: phucduc.bui
Cc: Linus Walleij, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Kuninori Morimoto, Charles Keepax, u.kleine-koenig, Igor Prusov,
linux-sound, linux-kernel
On Thu, 22 Oct 2026 17:26:37 +0700, phucduc.bui@gmail.com wrote:
> ASoC: codecs: ntp8918: Fix hw_params return values
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5
Thanks!
[1/2] ASoC: codecs: ntp8918: Fix hw_params return values
https://git.kernel.org/broonie/sound/c/972483b70fbe
[2/2] ASoC: codecs: ntp8835: Fix hw_params return values
https://git.kernel.org/broonie/sound/c/dd1112e7907f
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] 3+ messages in thread
end of thread, other threads:[~2026-11-02 13:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22 10:26 [PATCH 1/2] ASoC: codecs: ntp8918: Fix hw_params return values phucduc.bui
2026-10-22 10:26 ` [PATCH 2/2] ASoC: codecs: ntp8835: " phucduc.bui
2026-11-02 0:24 ` [PATCH 1/2] ASoC: codecs: ntp8918: " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox