]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: samsung: idma: Use guard() for spin locks
authorbui duc phuc <phucduc.bui@gmail.com>
Thu, 23 Apr 2026 12:56:43 +0000 (19:56 +0700)
committerMark Brown <broonie@kernel.org>
Sun, 26 Apr 2026 23:28:17 +0000 (08:28 +0900)
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/20260423125646.156599-3-phucduc.bui@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/samsung/idma.c

index cb455ddce25326c34aebeb3ce0cfc3c315e3e766..d362136e1069c1091974d6fa28872869fdc3ae2b 100644 (file)
@@ -67,9 +67,8 @@ static int idma_enqueue(struct snd_pcm_substream *substream)
        struct idma_ctrl *prtd = substream->runtime->private_data;
        u32 val;
 
-       spin_lock(&prtd->lock);
-       prtd->token = (void *) substream;
-       spin_unlock(&prtd->lock);
+       scoped_guard(spinlock, &prtd->lock)
+               prtd->token = (void *) substream;
 
        /* Internal DMA Level0 Interrupt Address */
        val = idma.lp_tx_addr + prtd->periodsz;
@@ -101,16 +100,15 @@ static void idma_setcallbk(struct snd_pcm_substream *substream,
 {
        struct idma_ctrl *prtd = substream->runtime->private_data;
 
-       spin_lock(&prtd->lock);
+       guard(spinlock)(&prtd->lock);
        prtd->cb = cb;
-       spin_unlock(&prtd->lock);
 }
 
 static void idma_control(int op)
 {
        u32 val = readl(idma.regs + I2SAHB);
 
-       spin_lock(&idma.lock);
+       guard(spinlock)(&idma.lock);
 
        switch (op) {
        case LPAM_DMA_START:
@@ -120,12 +118,10 @@ static void idma_control(int op)
                val &= ~(AHB_INTENLVL0 | AHB_DMAEN);
                break;
        default:
-               spin_unlock(&idma.lock);
                return;
        }
 
        writel(val, idma.regs + I2SAHB);
-       spin_unlock(&idma.lock);
 }
 
 static void idma_done(void *id, int bytes_xfer)
@@ -192,7 +188,7 @@ static int idma_trigger(struct snd_soc_component *component,
        struct idma_ctrl *prtd = substream->runtime->private_data;
        int ret = 0;
 
-       spin_lock(&prtd->lock);
+       guard(spinlock)(&prtd->lock);
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_RESUME:
@@ -214,8 +210,6 @@ static int idma_trigger(struct snd_soc_component *component,
                break;
        }
 
-       spin_unlock(&prtd->lock);
-
        return ret;
 }
 
@@ -228,12 +222,10 @@ idma_pointer(struct snd_soc_component *component,
        dma_addr_t src;
        unsigned long res;
 
-       spin_lock(&prtd->lock);
-
-       idma_getpos(&src);
-       res = src - prtd->start;
-
-       spin_unlock(&prtd->lock);
+       scoped_guard(spinlock, &prtd->lock) {
+               idma_getpos(&src);
+               res = src - prtd->start;
+       }
 
        return bytes_to_frames(substream->runtime, res);
 }