]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: cs5535audio: Use guard() for spin locks
authorTakashi Iwai <tiwai@suse.de>
Fri, 29 Aug 2025 14:42:56 +0000 (16:42 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 1 Sep 2025 11:52:40 +0000 (13:52 +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>
Link: https://patch.msgid.link/20250829144342.4290-22-tiwai@suse.de
sound/pci/cs5535audio/cs5535audio.c
sound/pci/cs5535audio/cs5535audio_pcm.c

index 76566e7baea0a804d9bb9d1513e87290a86b66ef..0ebf6c02b1effd125beae3c36536318eb09caa3b 100644 (file)
@@ -176,9 +176,10 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
 static void process_bm0_irq(struct cs5535audio *cs5535au)
 {
        u8 bm_stat;
-       spin_lock(&cs5535au->reg_lock);
-       bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS);
-       spin_unlock(&cs5535au->reg_lock);
+
+       scoped_guard(spinlock, &cs5535au->reg_lock) {
+               bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS);
+       }
        if (bm_stat & EOP) {
                snd_pcm_period_elapsed(cs5535au->playback_substream);
        } else {
@@ -191,9 +192,10 @@ static void process_bm0_irq(struct cs5535audio *cs5535au)
 static void process_bm1_irq(struct cs5535audio *cs5535au)
 {
        u8 bm_stat;
-       spin_lock(&cs5535au->reg_lock);
-       bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS);
-       spin_unlock(&cs5535au->reg_lock);
+
+       scoped_guard(spinlock, &cs5535au->reg_lock) {
+               bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS);
+       }
        if (bm_stat & EOP)
                snd_pcm_period_elapsed(cs5535au->capture_substream);
 }
index f296b2c630265cfaeda62d6ce7ebcaffe89b3eab..48b99a07e3bc18ee9c16b2824b27885b6cea67c5 100644 (file)
@@ -150,10 +150,9 @@ static int cs5535audio_build_dma_packets(struct cs5535audio *cs5535au,
        dma->substream = substream;
        dma->period_bytes = period_bytes;
        dma->periods = periods;
-       spin_lock_irq(&cs5535au->reg_lock);
+       guard(spinlock_irq)(&cs5535au->reg_lock);
        dma->ops->disable_dma(cs5535au);
        dma->ops->setup_prd(cs5535au, jmpprd_addr);
-       spin_unlock_irq(&cs5535au->reg_lock);
        return 0;
 }
 
@@ -276,9 +275,8 @@ static int snd_cs5535audio_trigger(struct snd_pcm_substream *substream, int cmd)
 {
        struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream);
        struct cs5535audio_dma *dma = substream->runtime->private_data;
-       int err = 0;
 
-       spin_lock(&cs5535au->reg_lock);
+       guard(spinlock)(&cs5535au->reg_lock);
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                dma->ops->pause_dma(cs5535au);
@@ -300,11 +298,9 @@ static int snd_cs5535audio_trigger(struct snd_pcm_substream *substream, int cmd)
                break;
        default:
                dev_err(cs5535au->card->dev, "unhandled trigger\n");
-               err = -EINVAL;
-               break;
+               return -EINVAL;
        }
-       spin_unlock(&cs5535au->reg_lock);
-       return err;
+       return 0;
 }
 
 static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(struct snd_pcm_substream