]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: spi/at73c213: Use guard() for spin locks
authorTakashi Iwai <tiwai@suse.de>
Wed, 17 Sep 2025 11:12:49 +0000 (13:12 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 17 Sep 2025 12:07:02 +0000 (14:07 +0200)
Clean up the code using guard() for spin locks.

Merely code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/spi/at73c213.c

index 0ece7ccbd55fae99bd538a5aff4f00e7a025b95f..0c2394733dc4bbaf194d80c82acc8f59a0209ab7 100644 (file)
@@ -273,9 +273,8 @@ static int snd_at73c213_pcm_trigger(struct snd_pcm_substream *substream,
                                   int cmd)
 {
        struct snd_at73c213 *chip = snd_pcm_substream_chip(substream);
-       int retval = 0;
 
-       spin_lock(&chip->lock);
+       guard(spinlock)(&chip->lock);
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -288,13 +287,11 @@ static int snd_at73c213_pcm_trigger(struct snd_pcm_substream *substream,
                break;
        default:
                dev_dbg(&chip->spi->dev, "spurious command %x\n", cmd);
-               retval = -EINVAL;
+               return -EINVAL;
                break;
        }
 
-       spin_unlock(&chip->lock);
-
-       return retval;
+       return 0;
 }
 
 static snd_pcm_uframes_t
@@ -358,30 +355,29 @@ static irqreturn_t snd_at73c213_interrupt(int irq, void *dev_id)
        int next_period;
        int retval = IRQ_NONE;
 
-       spin_lock(&chip->lock);
+       scoped_guard(spinlock, &chip->lock) {
+               block_size = frames_to_bytes(runtime, runtime->period_size);
+               status = ssc_readl(chip->ssc->regs, IMR);
 
-       block_size = frames_to_bytes(runtime, runtime->period_size);
-       status = ssc_readl(chip->ssc->regs, IMR);
-
-       if (status & SSC_BIT(IMR_ENDTX)) {
-               chip->period++;
-               if (chip->period == runtime->periods)
-                       chip->period = 0;
-               next_period = chip->period + 1;
-               if (next_period == runtime->periods)
-                       next_period = 0;
-
-               offset = block_size * next_period;
-
-               ssc_writel(chip->ssc->regs, PDC_TNPR,
-                               (long)runtime->dma_addr + offset);
-               ssc_writel(chip->ssc->regs, PDC_TNCR,
-                               runtime->period_size * runtime->channels);
-               retval = IRQ_HANDLED;
-       }
+               if (status & SSC_BIT(IMR_ENDTX)) {
+                       chip->period++;
+                       if (chip->period == runtime->periods)
+                               chip->period = 0;
+                       next_period = chip->period + 1;
+                       if (next_period == runtime->periods)
+                               next_period = 0;
+
+                       offset = block_size * next_period;
 
-       ssc_readl(chip->ssc->regs, IMR);
-       spin_unlock(&chip->lock);
+                       ssc_writel(chip->ssc->regs, PDC_TNPR,
+                                  (long)runtime->dma_addr + offset);
+                       ssc_writel(chip->ssc->regs, PDC_TNCR,
+                                  runtime->period_size * runtime->channels);
+                       retval = IRQ_HANDLED;
+               }
+
+               ssc_readl(chip->ssc->regs, IMR);
+       }
 
        if (status & SSC_BIT(IMR_ENDTX))
                snd_pcm_period_elapsed(chip->substream);