[PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure
From: phucduc . bui
Date: Fri Nov 27 2026 - 04:24:23 EST
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Roll back the refcount when starting synchronization fails.
Disable interrupts if no users remain.
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---
sound/soc/stm/stm32_spdifrx.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c
index 467c3c583a00..ba6c715750aa 100644
--- a/sound/soc/stm/stm32_spdifrx.c
+++ b/sound/soc/stm/stm32_spdifrx.c
@@ -358,9 +358,15 @@ static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx)
cr_mask |= SPDIFRX_CR_SPDIFEN_MASK;
ret = regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR,
cr_mask, cr);
- if (ret < 0)
+ if (ret < 0) {
dev_err(&spdifrx->pdev->dev,
"Failed to start synchronization\n");
+ spdifrx->refcount--;
+ if (!spdifrx->refcount)
+ regmap_update_bits(spdifrx->regmap,
+ STM32_SPDIFRX_IMR,
+ SPDIFRX_XIMR_MASK, 0);
+ }
}
return ret;
--
2.43.0