All of lore.kernel.org
 help / color / mirror / Atom feed
From: phucduc.bui@gmail.com
To: Mark Brown <broonie@kernel.org>,
	Olivier Moysan <olivier.moysan@foss.st.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	linux-sound@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure
Date: Fri, 27 Nov 2026 16:23:44 +0700	[thread overview]
Message-ID: <20261127092345.12383-3-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20261127092345.12383-1-phucduc.bui@gmail.com>

From: bui duc phuc <phucduc.bui@gmail.com>

Roll back the refcount when starting synchronization fails.
Disable interrupts if no users remain.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 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


  parent reply	other threads:[~2026-11-27  9:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  9:23 [PATCH 0/3] ASoC: stm32: spdifrx: Fix resource handling and startup phucduc.bui
2026-11-27  9:23 ` [PATCH 1/3] ASoC: stm32: spdifrx: Use devm helpers and drop remove callback phucduc.bui
2026-12-01  8:52   ` Olivier MOYSAN
2026-12-01 11:41     ` Mark Brown
2026-11-27  9:23 ` phucduc.bui [this message]
2026-11-27  9:34   ` [PATCH 2/3] ASoC: stm32: spdifrx: Fix refcount on sync failure sashiko-bot
2026-11-27  9:41     ` Bui Duc Phuc
2026-11-30 17:18   ` Olivier MOYSAN
2026-12-01  8:35     ` Bui Duc Phuc
2026-11-27  9:23 ` [PATCH 3/3] ASoC: stm32: spdifrx: Enable clock before setting substream phucduc.bui
2026-11-27  9:28   ` sashiko-bot
2026-11-27  9:41     ` 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=20261127092345.12383-3-phucduc.bui@gmail.com \
    --to=phucduc.bui@gmail.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=arnaud.pouliquen@foss.st.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=olivier.moysan@foss.st.com \
    --cc=perex@perex.cz \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.