public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: uniphier: Use guard() for spin locks
@ 2026-04-29  9:16 phucduc.bui
  2026-04-29  9:16 ` [PATCH 1/2] ASoC: uniphier: aio-compress: " phucduc.bui
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: phucduc.bui @ 2026-04-29  9:16 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Jaroslav Kysela, Takashi Iwai, Kunihiko Hayashi, Masami Hiramatsu,
	Kuninori Morimoto, Joris Verhaegen, Miller Liang, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

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

Hi all,

This series converts spin lock handling in UniPhier AIO drivers
to use guard() helpers.
The changes are purely code cleanups with no functional impact.

Best regards,
Phuc

bui duc phuc (2):
  ASoC: uniphier: aio-compress: Use guard() for spin locks
  ASoC: uniphier: aio-dma: Use guard() for spin locks

 sound/soc/uniphier/aio-compress.c | 24 +++++---------
 sound/soc/uniphier/aio-dma.c      | 52 ++++++++++++++-----------------
 2 files changed, 30 insertions(+), 46 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] ASoC: uniphier: aio-compress: Use guard() for spin locks
  2026-04-29  9:16 [PATCH 0/2] ASoC: uniphier: Use guard() for spin locks phucduc.bui
@ 2026-04-29  9:16 ` phucduc.bui
  2026-04-29  9:16 ` [PATCH 2/2] ASoC: uniphier: aio-dma: " phucduc.bui
  2026-05-04 13:08 ` [PATCH 0/2] ASoC: uniphier: " Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-04-29  9:16 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Jaroslav Kysela, Takashi Iwai, Kunihiko Hayashi, Masami Hiramatsu,
	Kuninori Morimoto, Joris Verhaegen, Miller Liang, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

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

Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/uniphier/aio-compress.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/sound/soc/uniphier/aio-compress.c b/sound/soc/uniphier/aio-compress.c
index b18af98a552b..57247a03b5c9 100644
--- a/sound/soc/uniphier/aio-compress.c
+++ b/sound/soc/uniphier/aio-compress.c
@@ -183,18 +183,16 @@ static int uniphier_aio_compr_prepare(struct snd_soc_component *component,
 	struct uniphier_aio *aio = uniphier_priv(snd_soc_rtd_to_cpu(rtd, 0));
 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
 	int bytes = runtime->fragment_size;
-	unsigned long flags;
 	int ret;
 
 	ret = aiodma_ch_set_param(sub);
 	if (ret)
 		return ret;
 
-	spin_lock_irqsave(&sub->lock, flags);
-	ret = aiodma_rb_set_buffer(sub, sub->compr_addr,
-				   sub->compr_addr + sub->compr_bytes,
-				   bytes);
-	spin_unlock_irqrestore(&sub->lock, flags);
+	scoped_guard(spinlock_irqsave, &sub->lock)
+		ret = aiodma_rb_set_buffer(sub, sub->compr_addr,
+					   sub->compr_addr + sub->compr_bytes,
+					   bytes);
 	if (ret)
 		return ret;
 
@@ -223,9 +221,8 @@ static int uniphier_aio_compr_trigger(struct snd_soc_component *component,
 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
 	struct device *dev = &aio->chip->pdev->dev;
 	int bytes = runtime->fragment_size, ret = 0;
-	unsigned long flags;
 
-	spin_lock_irqsave(&sub->lock, flags);
+	guard(spinlock_irqsave)(&sub->lock);
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
 		aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes);
@@ -242,7 +239,6 @@ static int uniphier_aio_compr_trigger(struct snd_soc_component *component,
 		dev_warn(dev, "Unknown trigger(%d)\n", cmd);
 		ret = -EINVAL;
 	}
-	spin_unlock_irqrestore(&sub->lock, flags);
 
 	return ret;
 }
@@ -256,10 +252,9 @@ static int uniphier_aio_compr_pointer(struct snd_soc_component *component,
 	struct uniphier_aio *aio = uniphier_priv(snd_soc_rtd_to_cpu(rtd, 0));
 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
 	int bytes = runtime->fragment_size;
-	unsigned long flags;
 	u32 pos;
 
-	spin_lock_irqsave(&sub->lock, flags);
+	guard(spinlock_irqsave)(&sub->lock);
 
 	aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes);
 
@@ -273,8 +268,6 @@ static int uniphier_aio_compr_pointer(struct snd_soc_component *component,
 	}
 	tstamp->byte_offset = pos;
 
-	spin_unlock_irqrestore(&sub->lock, flags);
-
 	return 0;
 }
 
@@ -332,7 +325,6 @@ static int uniphier_aio_compr_copy(struct snd_soc_component *component,
 	struct uniphier_aio_sub *sub = &aio->sub[cstream->direction];
 	size_t cnt = min_t(size_t, count, aio_rb_space_to_end(sub) / 2);
 	int bytes = runtime->fragment_size;
-	unsigned long flags;
 	size_t s;
 	int ret;
 
@@ -360,7 +352,7 @@ static int uniphier_aio_compr_copy(struct snd_soc_component *component,
 	if (ret)
 		return -EFAULT;
 
-	spin_lock_irqsave(&sub->lock, flags);
+	guard(spinlock_irqsave)(&sub->lock);
 
 	sub->threshold = 2 * bytes;
 	aiodma_rb_set_threshold(sub, sub->compr_bytes, 2 * bytes);
@@ -376,8 +368,6 @@ static int uniphier_aio_compr_copy(struct snd_soc_component *component,
 	}
 	aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes);
 
-	spin_unlock_irqrestore(&sub->lock, flags);
-
 	return cnt;
 }
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] ASoC: uniphier: aio-dma: Use guard() for spin locks
  2026-04-29  9:16 [PATCH 0/2] ASoC: uniphier: Use guard() for spin locks phucduc.bui
  2026-04-29  9:16 ` [PATCH 1/2] ASoC: uniphier: aio-compress: " phucduc.bui
@ 2026-04-29  9:16 ` phucduc.bui
  2026-05-04 13:08 ` [PATCH 0/2] ASoC: uniphier: " Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-04-29  9:16 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Jaroslav Kysela, Takashi Iwai, Kunihiko Hayashi, Masami Hiramatsu,
	Kuninori Morimoto, Joris Verhaegen, Miller Liang, linux-sound,
	linux-arm-kernel, linux-kernel, bui duc phuc

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

Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/uniphier/aio-dma.c | 52 ++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 29 deletions(-)

diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c
index c1ca55997103..c01eae55d4fc 100644
--- a/sound/soc/uniphier/aio-dma.c
+++ b/sound/soc/uniphier/aio-dma.c
@@ -32,15 +32,15 @@ static void aiodma_pcm_irq(struct uniphier_aio_sub *sub)
 		runtime->channels * samples_to_bytes(runtime, 1);
 	int ret;
 
-	spin_lock(&sub->lock);
-	ret = aiodma_rb_set_threshold(sub, runtime->dma_bytes,
-				      sub->threshold + bytes);
-	if (!ret)
-		sub->threshold += bytes;
-
-	aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, bytes);
-	aiodma_rb_clear_irq(sub);
-	spin_unlock(&sub->lock);
+	scoped_guard(spinlock, &sub->lock) {
+		ret = aiodma_rb_set_threshold(sub, runtime->dma_bytes,
+					      sub->threshold + bytes);
+		if (!ret)
+			sub->threshold += bytes;
+
+		aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, bytes);
+		aiodma_rb_clear_irq(sub);
+	}
 
 	snd_pcm_period_elapsed(sub->substream);
 }
@@ -51,15 +51,15 @@ static void aiodma_compr_irq(struct uniphier_aio_sub *sub)
 	int bytes = runtime->fragment_size;
 	int ret;
 
-	spin_lock(&sub->lock);
-	ret = aiodma_rb_set_threshold(sub, sub->compr_bytes,
-				      sub->threshold + bytes);
-	if (!ret)
-		sub->threshold += bytes;
+	scoped_guard(spinlock, &sub->lock) {
+		ret = aiodma_rb_set_threshold(sub, sub->compr_bytes,
+					      sub->threshold + bytes);
+		if (!ret)
+			sub->threshold += bytes;
 
-	aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes);
-	aiodma_rb_clear_irq(sub);
-	spin_unlock(&sub->lock);
+		aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes);
+		aiodma_rb_clear_irq(sub);
+	}
 
 	snd_compr_fragment_elapsed(sub->cstream);
 }
@@ -113,18 +113,16 @@ static int uniphier_aiodma_prepare(struct snd_soc_component *component,
 	struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
 	int bytes = runtime->period_size *
 		runtime->channels * samples_to_bytes(runtime, 1);
-	unsigned long flags;
 	int ret;
 
 	ret = aiodma_ch_set_param(sub);
 	if (ret)
 		return ret;
 
-	spin_lock_irqsave(&sub->lock, flags);
-	ret = aiodma_rb_set_buffer(sub, runtime->dma_addr,
-				   runtime->dma_addr + runtime->dma_bytes,
-				   bytes);
-	spin_unlock_irqrestore(&sub->lock, flags);
+	scoped_guard(spinlock_irqsave, &sub->lock)
+		ret = aiodma_rb_set_buffer(sub, runtime->dma_addr,
+					   runtime->dma_addr + runtime->dma_bytes,
+					   bytes);
 	if (ret)
 		return ret;
 
@@ -141,9 +139,8 @@ static int uniphier_aiodma_trigger(struct snd_soc_component *component,
 	struct device *dev = &aio->chip->pdev->dev;
 	int bytes = runtime->period_size *
 		runtime->channels * samples_to_bytes(runtime, 1);
-	unsigned long flags;
 
-	spin_lock_irqsave(&sub->lock, flags);
+	guard(spinlock_irqsave)(&sub->lock);
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
 		aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes,
@@ -161,7 +158,6 @@ static int uniphier_aiodma_trigger(struct snd_soc_component *component,
 		dev_warn(dev, "Unknown trigger(%d) ignored\n", cmd);
 		break;
 	}
-	spin_unlock_irqrestore(&sub->lock, flags);
 
 	return 0;
 }
@@ -176,17 +172,15 @@ static snd_pcm_uframes_t uniphier_aiodma_pointer(
 	struct uniphier_aio_sub *sub = &aio->sub[substream->stream];
 	int bytes = runtime->period_size *
 		runtime->channels * samples_to_bytes(runtime, 1);
-	unsigned long flags;
 	snd_pcm_uframes_t pos;
 
-	spin_lock_irqsave(&sub->lock, flags);
+	guard(spinlock_irqsave)(&sub->lock);
 	aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, bytes);
 
 	if (sub->swm->dir == PORT_DIR_OUTPUT)
 		pos = bytes_to_frames(runtime, sub->rd_offs);
 	else
 		pos = bytes_to_frames(runtime, sub->wr_offs);
-	spin_unlock_irqrestore(&sub->lock, flags);
 
 	return pos;
 }
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] ASoC: uniphier: Use guard() for spin locks
  2026-04-29  9:16 [PATCH 0/2] ASoC: uniphier: Use guard() for spin locks phucduc.bui
  2026-04-29  9:16 ` [PATCH 1/2] ASoC: uniphier: aio-compress: " phucduc.bui
  2026-04-29  9:16 ` [PATCH 2/2] ASoC: uniphier: aio-dma: " phucduc.bui
@ 2026-05-04 13:08 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-05-04 13:08 UTC (permalink / raw)
  To: Liam Girdwood, phucduc.bui
  Cc: Jaroslav Kysela, Takashi Iwai, Kunihiko Hayashi, Masami Hiramatsu,
	Kuninori Morimoto, Joris Verhaegen, Miller Liang, linux-sound,
	linux-arm-kernel, linux-kernel

On Wed, 29 Apr 2026 16:16:12 +0700, phucduc.bui@gmail.com wrote:
> ASoC: uniphier: Use guard() for spin locks
> 
> From: bui duc phuc <phucduc.bui@gmail.com>
> 
> Hi all,
> 
> This series converts spin lock handling in UniPhier AIO drivers
> to use guard() helpers.
> The changes are purely code cleanups with no functional impact.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/2] ASoC: uniphier: aio-compress: Use guard() for spin locks
      https://git.kernel.org/broonie/sound/c/55f8c382858d
[2/2] ASoC: uniphier: aio-dma: Use guard() for spin locks
      https://git.kernel.org/broonie/sound/c/8f7e9d3c0cca

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-05  1:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29  9:16 [PATCH 0/2] ASoC: uniphier: Use guard() for spin locks phucduc.bui
2026-04-29  9:16 ` [PATCH 1/2] ASoC: uniphier: aio-compress: " phucduc.bui
2026-04-29  9:16 ` [PATCH 2/2] ASoC: uniphier: aio-dma: " phucduc.bui
2026-05-04 13:08 ` [PATCH 0/2] ASoC: uniphier: " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox