]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: sti: uniperif_reader: Use guard() for spin locks
authorbui duc phuc <phucduc.bui@gmail.com>
Wed, 27 May 2026 10:02:05 +0000 (17:02 +0700)
committerMark Brown <broonie@kernel.org>
Mon, 1 Jun 2026 15:47:06 +0000 (16:47 +0100)
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>
Link: https://patch.msgid.link/20260527100206.26788-2-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sti/uniperif_reader.c

index 05ea2b794eb92563d4a53ac66791ae6780796b6a..45d7613f595cce88c8445c30334d0f38e8a4c633 100644 (file)
@@ -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 = {