]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: atiixp: Use guard() for mutex locks
authorTakashi Iwai <tiwai@suse.de>
Fri, 29 Aug 2025 14:42:45 +0000 (16:42 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 1 Sep 2025 11:52:39 +0000 (13:52 +0200)
Replace the manual mutex lock/unlock pairs with guard() for code
simplification.

Only code refactoring, and no behavior change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250829144342.4290-11-tiwai@suse.de
sound/pci/atiixp.c
sound/pci/atiixp_modem.c

index 4f544950ee7bf116379a6cf00d50940587f39491..38c07f3de850211b732fa08381874098d0590c86 100644 (file)
@@ -1073,9 +1073,8 @@ static int snd_atiixp_playback_open(struct snd_pcm_substream *substream)
        struct atiixp *chip = snd_pcm_substream_chip(substream);
        int err;
 
-       mutex_lock(&chip->open_mutex);
+       guard(mutex)(&chip->open_mutex);
        err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0);
-       mutex_unlock(&chip->open_mutex);
        if (err < 0)
                return err;
        substream->runtime->hw.channels_max = chip->max_channels;
@@ -1089,11 +1088,9 @@ static int snd_atiixp_playback_open(struct snd_pcm_substream *substream)
 static int snd_atiixp_playback_close(struct snd_pcm_substream *substream)
 {
        struct atiixp *chip = snd_pcm_substream_chip(substream);
-       int err;
-       mutex_lock(&chip->open_mutex);
-       err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
-       mutex_unlock(&chip->open_mutex);
-       return err;
+
+       guard(mutex)(&chip->open_mutex);
+       return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
 }
 
 static int snd_atiixp_capture_open(struct snd_pcm_substream *substream)
@@ -1111,27 +1108,23 @@ static int snd_atiixp_capture_close(struct snd_pcm_substream *substream)
 static int snd_atiixp_spdif_open(struct snd_pcm_substream *substream)
 {
        struct atiixp *chip = snd_pcm_substream_chip(substream);
-       int err;
-       mutex_lock(&chip->open_mutex);
+
+       guard(mutex)(&chip->open_mutex);
        if (chip->spdif_over_aclink) /* share DMA_PLAYBACK */
-               err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 2);
+               return snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 2);
        else
-               err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_SPDIF], -1);
-       mutex_unlock(&chip->open_mutex);
-       return err;
+               return snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_SPDIF], -1);
 }
 
 static int snd_atiixp_spdif_close(struct snd_pcm_substream *substream)
 {
        struct atiixp *chip = snd_pcm_substream_chip(substream);
-       int err;
-       mutex_lock(&chip->open_mutex);
+
+       guard(mutex)(&chip->open_mutex);
        if (chip->spdif_over_aclink)
-               err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
+               return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
        else
-               err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_SPDIF]);
-       mutex_unlock(&chip->open_mutex);
-       return err;
+               return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_SPDIF]);
 }
 
 /* AC97 playback */
index f7417c2bb477653916852c2605122c88b3a7f518..81a53336699ed930a740f7860cebc1f923aa885e 100644 (file)
@@ -892,24 +892,17 @@ static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
 static int snd_atiixp_playback_open(struct snd_pcm_substream *substream)
 {
        struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
-       int err;
 
-       mutex_lock(&chip->open_mutex);
-       err = snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0);
-       mutex_unlock(&chip->open_mutex);
-       if (err < 0)
-               return err;
-       return 0;
+       guard(mutex)(&chip->open_mutex);
+       return snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_PLAYBACK], 0);
 }
 
 static int snd_atiixp_playback_close(struct snd_pcm_substream *substream)
 {
        struct atiixp_modem *chip = snd_pcm_substream_chip(substream);
-       int err;
-       mutex_lock(&chip->open_mutex);
-       err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
-       mutex_unlock(&chip->open_mutex);
-       return err;
+
+       guard(mutex)(&chip->open_mutex);
+       return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]);
 }
 
 static int snd_atiixp_capture_open(struct snd_pcm_substream *substream)