From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>
Cc: Linus Walleij <linusw@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
u.kleine-koenig@baylibre.com,
Igor Prusov <ivprusov@salutedevices.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 1/2] ASoC: codecs: ntp8918: Fix hw_params return values
Date: Thu, 22 Oct 2026 17:26:37 +0700 [thread overview]
Message-ID: <20261022102638.38606-1-phucduc.bui@gmail.com> (raw)
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
next reply other threads:[~2026-10-22 10:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 10:26 phucduc.bui [this message]
2026-10-22 10:26 ` [PATCH 2/2] ASoC: codecs: ntp8835: " phucduc.bui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261022102638.38606-1-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=ivprusov@salutedevices.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=u.kleine-koenig@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®