From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
bcm-kernel-feedback-list@broadcom.com
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
linux-sound@vger.kernel.org, Kees Cook <kees+treewide@kernel.org>,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 2/2] ASoC: bcm2835-i2s: Check clock enable return value
Date: Thu, 3 Dec 2026 13:34:34 +0700 [thread overview]
Message-ID: <20261203063435.13517-3-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20261203063435.13517-1-phucduc.bui@gmail.com>
From: bui duc phuc <phucduc.bui@gmail.com>
bcm2835_i2s_start_clock() ignores the return value of
clk_prepare_enable() and marks the clock as prepared even on failure,
so bcm2835_i2s_stop_clock() later disables a clock that was never
enabled.
Return the error and only set clk_prepared on success. Propagate it
from .hw_params, and skip clearing the FIFOs in
bcm2835_i2s_clear_fifos(), which cannot be done without the clock.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
sound/soc/bcm/bcm2835-i2s.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c
index 68be1ded6f93..f367ca070e3a 100644
--- a/sound/soc/bcm/bcm2835-i2s.c
+++ b/sound/soc/bcm/bcm2835-i2s.c
@@ -125,22 +125,29 @@ struct bcm2835_i2s_dev {
int clk_rate;
};
-static void bcm2835_i2s_start_clock(struct bcm2835_i2s_dev *dev)
+static int bcm2835_i2s_start_clock(struct bcm2835_i2s_dev *dev)
{
unsigned int provider = dev->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK;
+ int ret;
if (dev->clk_prepared)
- return;
+ return 0;
switch (provider) {
case SND_SOC_DAIFMT_BP_FP:
case SND_SOC_DAIFMT_BP_FC:
- clk_prepare_enable(dev->clk);
+ ret = clk_prepare_enable(dev->clk);
+ if (ret) {
+ dev_err(dev->dev, "Failed to enable clock: %d\n", ret);
+ return ret;
+ }
dev->clk_prepared = true;
break;
default:
break;
}
+
+ return 0;
}
static void bcm2835_i2s_stop_clock(struct bcm2835_i2s_dev *dev)
@@ -154,6 +161,7 @@ static void bcm2835_i2s_clear_fifos(struct bcm2835_i2s_dev *dev,
bool tx, bool rx)
{
int timeout = 1000;
+ int ret;
uint32_t syncval;
uint32_t csreg;
uint32_t i2s_active_state;
@@ -173,8 +181,11 @@ static void bcm2835_i2s_clear_fifos(struct bcm2835_i2s_dev *dev,
/* Start clock if not running */
clk_was_prepared = dev->clk_prepared;
- if (!clk_was_prepared)
- bcm2835_i2s_start_clock(dev);
+ if (!clk_was_prepared) {
+ ret = bcm2835_i2s_start_clock(dev);
+ if (ret)
+ return;
+ }
/* Stop I2S module */
regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, off, 0);
@@ -424,7 +435,9 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream,
dev->clk_rate = bclk_rate;
}
- bcm2835_i2s_start_clock(dev);
+ ret = bcm2835_i2s_start_clock(dev);
+ if (ret)
+ return ret;
}
/* Setup the frame format */
--
2.43.0
next prev parent reply other threads:[~2026-12-03 6:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 6:34 [PATCH 0/2] ASoC: bcm2835-i2s: Fix clock handling phucduc.bui
2026-12-03 6:34 ` [PATCH 1/2] ASoC: bcm2835-i2s: Remove redundant clock start/stop in trigger path phucduc.bui
2026-12-03 6:34 ` phucduc.bui [this message]
2026-12-03 6:51 ` [PATCH 2/2] ASoC: bcm2835-i2s: Check clock enable return value sashiko-bot
2026-12-03 7:15 ` Bui Duc Phuc
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=20261203063435.13517-3-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=broonie@kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=kees+treewide@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=tiwai@suse.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