* [PATCH 1/2] ASoC: sti: uniperif_reader: Use guard() for spin locks
2026-05-27 10:02 [PATCH 0/2] ASoC: sti: Use guard() for mutex & " phucduc.bui
@ 2026-05-27 10:02 ` phucduc.bui
0 siblings, 0 replies; 3+ messages in thread
From: phucduc.bui @ 2026-05-27 10:02 UTC (permalink / raw)
To: Mark Brown, Arnaud Pouliquen
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
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>
---
Compile-tested only.
sound/soc/sti/uniperif_reader.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/sound/soc/sti/uniperif_reader.c b/sound/soc/sti/uniperif_reader.c
index 05ea2b794eb9..45d7613f595c 100644
--- a/sound/soc/sti/uniperif_reader.c
+++ b/sound/soc/sti/uniperif_reader.c
@@ -46,15 +46,16 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
struct uniperif *reader = dev_id;
unsigned int status;
- spin_lock(&reader->irq_lock);
+ guard(spinlock)(&reader->irq_lock);
if (!reader->substream)
- goto irq_spin_unlock;
+ return ret;
snd_pcm_stream_lock(reader->substream);
if (reader->state == UNIPERIF_STATE_STOPPED) {
/* Unexpected IRQ: do nothing */
dev_warn(reader->dev, "unexpected IRQ\n");
- goto stream_unlock;
+ snd_pcm_stream_unlock(reader->substream);
+ return ret;
}
/* Get interrupt status & clear them immediately */
@@ -70,10 +71,7 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
ret = IRQ_HANDLED;
}
-stream_unlock:
snd_pcm_stream_unlock(reader->substream);
-irq_spin_unlock:
- spin_unlock(&reader->irq_lock);
return ret;
}
@@ -355,12 +353,10 @@ static int uni_reader_startup(struct snd_pcm_substream *substream,
{
struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
struct uniperif *reader = priv->dai_data.uni;
- unsigned long flags;
int ret;
- spin_lock_irqsave(&reader->irq_lock, flags);
- reader->substream = substream;
- spin_unlock_irqrestore(&reader->irq_lock, flags);
+ scoped_guard(spinlock_irqsave, &reader->irq_lock)
+ reader->substream = substream;
if (!UNIPERIF_TYPE_IS_TDM(reader))
return 0;
@@ -386,15 +382,13 @@ static void uni_reader_shutdown(struct snd_pcm_substream *substream,
{
struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
struct uniperif *reader = priv->dai_data.uni;
- unsigned long flags;
- spin_lock_irqsave(&reader->irq_lock, flags);
+ guard(spinlock_irqsave)(&reader->irq_lock);
if (reader->state != UNIPERIF_STATE_STOPPED) {
/* Stop the reader */
uni_reader_stop(reader);
}
reader->substream = NULL;
- spin_unlock_irqrestore(&reader->irq_lock, flags);
}
static const struct snd_soc_dai_ops uni_reader_dai_ops = {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 1/2] ASoC: sti: uniperif_reader: Use guard() for spin locks
@ 2026-05-28 5:30 phucduc.bui
2026-05-28 5:37 ` Bui Duc Phuc
0 siblings, 1 reply; 3+ messages in thread
From: phucduc.bui @ 2026-05-28 5:30 UTC (permalink / raw)
To: Mark Brown, Greg Kroah-Hartman
Cc: Rafael J . Wysocki, Danilo Krummrich, driver-core, 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>
---
Compile-tested only.
sound/soc/sti/uniperif_reader.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/sound/soc/sti/uniperif_reader.c b/sound/soc/sti/uniperif_reader.c
index 05ea2b794eb9..45d7613f595c 100644
--- a/sound/soc/sti/uniperif_reader.c
+++ b/sound/soc/sti/uniperif_reader.c
@@ -46,15 +46,16 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
struct uniperif *reader = dev_id;
unsigned int status;
- spin_lock(&reader->irq_lock);
+ guard(spinlock)(&reader->irq_lock);
if (!reader->substream)
- goto irq_spin_unlock;
+ return ret;
snd_pcm_stream_lock(reader->substream);
if (reader->state == UNIPERIF_STATE_STOPPED) {
/* Unexpected IRQ: do nothing */
dev_warn(reader->dev, "unexpected IRQ\n");
- goto stream_unlock;
+ snd_pcm_stream_unlock(reader->substream);
+ return ret;
}
/* Get interrupt status & clear them immediately */
@@ -70,10 +71,7 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
ret = IRQ_HANDLED;
}
-stream_unlock:
snd_pcm_stream_unlock(reader->substream);
-irq_spin_unlock:
- spin_unlock(&reader->irq_lock);
return ret;
}
@@ -355,12 +353,10 @@ static int uni_reader_startup(struct snd_pcm_substream *substream,
{
struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
struct uniperif *reader = priv->dai_data.uni;
- unsigned long flags;
int ret;
- spin_lock_irqsave(&reader->irq_lock, flags);
- reader->substream = substream;
- spin_unlock_irqrestore(&reader->irq_lock, flags);
+ scoped_guard(spinlock_irqsave, &reader->irq_lock)
+ reader->substream = substream;
if (!UNIPERIF_TYPE_IS_TDM(reader))
return 0;
@@ -386,15 +382,13 @@ static void uni_reader_shutdown(struct snd_pcm_substream *substream,
{
struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
struct uniperif *reader = priv->dai_data.uni;
- unsigned long flags;
- spin_lock_irqsave(&reader->irq_lock, flags);
+ guard(spinlock_irqsave)(&reader->irq_lock);
if (reader->state != UNIPERIF_STATE_STOPPED) {
/* Stop the reader */
uni_reader_stop(reader);
}
reader->substream = NULL;
- spin_unlock_irqrestore(&reader->irq_lock, flags);
}
static const struct snd_soc_dai_ops uni_reader_dai_ops = {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] ASoC: sti: uniperif_reader: Use guard() for spin locks
2026-05-28 5:30 [PATCH 1/2] ASoC: sti: uniperif_reader: Use guard() for spin locks phucduc.bui
@ 2026-05-28 5:37 ` Bui Duc Phuc
0 siblings, 0 replies; 3+ messages in thread
From: Bui Duc Phuc @ 2026-05-28 5:37 UTC (permalink / raw)
To: Mark Brown, Greg Kroah-Hartman
Cc: Rafael J . Wysocki, Danilo Krummrich, driver-core, linux-kernel
Hi all,
Sorry, I sent the wrong patch by mistake.
Please ignore this patch and refer to the correct patch here:
https://lore.kernel.org/all/20260528053204.46783-1-phucduc.bui@gmail.com/
Best Regards,
Phuc
On Thu, May 28, 2026 at 12:30 PM <phucduc.bui@gmail.com> wrote:
>
> 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>
> ---
>
> Compile-tested only.
>
> sound/soc/sti/uniperif_reader.c | 20 +++++++-------------
> 1 file changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/sound/soc/sti/uniperif_reader.c b/sound/soc/sti/uniperif_reader.c
> index 05ea2b794eb9..45d7613f595c 100644
> --- a/sound/soc/sti/uniperif_reader.c
> +++ b/sound/soc/sti/uniperif_reader.c
> @@ -46,15 +46,16 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
> struct uniperif *reader = dev_id;
> unsigned int status;
>
> - spin_lock(&reader->irq_lock);
> + guard(spinlock)(&reader->irq_lock);
> if (!reader->substream)
> - goto irq_spin_unlock;
> + return ret;
>
> snd_pcm_stream_lock(reader->substream);
> if (reader->state == UNIPERIF_STATE_STOPPED) {
> /* Unexpected IRQ: do nothing */
> dev_warn(reader->dev, "unexpected IRQ\n");
> - goto stream_unlock;
> + snd_pcm_stream_unlock(reader->substream);
> + return ret;
> }
>
> /* Get interrupt status & clear them immediately */
> @@ -70,10 +71,7 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
> ret = IRQ_HANDLED;
> }
>
> -stream_unlock:
> snd_pcm_stream_unlock(reader->substream);
> -irq_spin_unlock:
> - spin_unlock(&reader->irq_lock);
>
> return ret;
> }
> @@ -355,12 +353,10 @@ static int uni_reader_startup(struct snd_pcm_substream *substream,
> {
> struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
> struct uniperif *reader = priv->dai_data.uni;
> - unsigned long flags;
> int ret;
>
> - spin_lock_irqsave(&reader->irq_lock, flags);
> - reader->substream = substream;
> - spin_unlock_irqrestore(&reader->irq_lock, flags);
> + scoped_guard(spinlock_irqsave, &reader->irq_lock)
> + reader->substream = substream;
>
> if (!UNIPERIF_TYPE_IS_TDM(reader))
> return 0;
> @@ -386,15 +382,13 @@ static void uni_reader_shutdown(struct snd_pcm_substream *substream,
> {
> struct sti_uniperiph_data *priv = snd_soc_dai_get_drvdata(dai);
> struct uniperif *reader = priv->dai_data.uni;
> - unsigned long flags;
>
> - spin_lock_irqsave(&reader->irq_lock, flags);
> + guard(spinlock_irqsave)(&reader->irq_lock);
> if (reader->state != UNIPERIF_STATE_STOPPED) {
> /* Stop the reader */
> uni_reader_stop(reader);
> }
> reader->substream = NULL;
> - spin_unlock_irqrestore(&reader->irq_lock, flags);
> }
>
> static const struct snd_soc_dai_ops uni_reader_dai_ops = {
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-28 5:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-28 5:30 [PATCH 1/2] ASoC: sti: uniperif_reader: Use guard() for spin locks phucduc.bui
2026-05-28 5:37 ` Bui Duc Phuc
-- strict thread matches above, loose matches on Subject: below --
2026-05-27 10:02 [PATCH 0/2] ASoC: sti: Use guard() for mutex & " phucduc.bui
2026-05-27 10:02 ` [PATCH 1/2] ASoC: sti: uniperif_reader: Use guard() for " phucduc.bui
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.