[PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream

From: phucduc . bui

Date: Fri Nov 27 2026 - 04:24:29 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

Enable the clock before assigning the substream to avoid leaving
a stale substream pointer if clock enabling fails.

Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/stm/stm32_spdifrx.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c
index ba6c715750aa..1d62a6fdc472 100644
--- a/sound/soc/stm/stm32_spdifrx.c
+++ b/sound/soc/stm/stm32_spdifrx.c
@@ -753,14 +753,16 @@ static int stm32_spdifrx_startup(struct snd_pcm_substream *substream,
struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai);
int ret;

+ ret = clk_prepare_enable(spdifrx->kclk);
+ if (ret) {
+ dev_err(&spdifrx->pdev->dev, "Enable kclk failed: %d\n", ret);
+ return ret;
+ }
+
scoped_guard(spinlock_irqsave, &spdifrx->irq_lock)
spdifrx->substream = substream;

- ret = clk_prepare_enable(spdifrx->kclk);
- if (ret)
- dev_err(&spdifrx->pdev->dev, "Enable kclk failed: %d\n", ret);
-
- return ret;
+ return 0;
}

static int stm32_spdifrx_hw_params(struct snd_pcm_substream *substream,
--
2.43.0