]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: atmel: Use guard() for mutex locks
authorTakashi Iwai <tiwai@suse.de>
Fri, 29 Aug 2025 15:13:30 +0000 (17:13 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 1 Sep 2025 11:54:28 +0000 (13:54 +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/20250829151335.7342-17-tiwai@suse.de
sound/atmel/ac97c.c

index 693d48f08b88be3f86e5cb02e19bb91a31ebb671..df0a049192deebe2a6e796af162710c6d84f20f3 100644 (file)
@@ -88,7 +88,7 @@ static int atmel_ac97c_playback_open(struct snd_pcm_substream *substream)
        struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       mutex_lock(&opened_mutex);
+       guard(mutex)(&opened_mutex);
        chip->opened++;
        runtime->hw = atmel_ac97c_hw;
        if (chip->cur_rate) {
@@ -97,7 +97,6 @@ static int atmel_ac97c_playback_open(struct snd_pcm_substream *substream)
        }
        if (chip->cur_format)
                runtime->hw.formats = pcm_format_to_bits(chip->cur_format);
-       mutex_unlock(&opened_mutex);
        chip->playback_substream = substream;
        return 0;
 }
@@ -107,7 +106,7 @@ static int atmel_ac97c_capture_open(struct snd_pcm_substream *substream)
        struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       mutex_lock(&opened_mutex);
+       guard(mutex)(&opened_mutex);
        chip->opened++;
        runtime->hw = atmel_ac97c_hw;
        if (chip->cur_rate) {
@@ -116,7 +115,6 @@ static int atmel_ac97c_capture_open(struct snd_pcm_substream *substream)
        }
        if (chip->cur_format)
                runtime->hw.formats = pcm_format_to_bits(chip->cur_format);
-       mutex_unlock(&opened_mutex);
        chip->capture_substream = substream;
        return 0;
 }
@@ -125,13 +123,12 @@ static int atmel_ac97c_playback_close(struct snd_pcm_substream *substream)
 {
        struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
 
-       mutex_lock(&opened_mutex);
+       guard(mutex)(&opened_mutex);
        chip->opened--;
        if (!chip->opened) {
                chip->cur_rate = 0;
                chip->cur_format = 0;
        }
-       mutex_unlock(&opened_mutex);
 
        chip->playback_substream = NULL;
 
@@ -142,13 +139,12 @@ static int atmel_ac97c_capture_close(struct snd_pcm_substream *substream)
 {
        struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
 
-       mutex_lock(&opened_mutex);
+       guard(mutex)(&opened_mutex);
        chip->opened--;
        if (!chip->opened) {
                chip->cur_rate = 0;
                chip->cur_format = 0;
        }
-       mutex_unlock(&opened_mutex);
 
        chip->capture_substream = NULL;
 
@@ -161,10 +157,9 @@ static int atmel_ac97c_playback_hw_params(struct snd_pcm_substream *substream,
        struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
 
        /* Set restrictions to params. */
-       mutex_lock(&opened_mutex);
+       guard(mutex)(&opened_mutex);
        chip->cur_rate = params_rate(hw_params);
        chip->cur_format = params_format(hw_params);
-       mutex_unlock(&opened_mutex);
 
        return 0;
 }
@@ -175,10 +170,9 @@ static int atmel_ac97c_capture_hw_params(struct snd_pcm_substream *substream,
        struct atmel_ac97c *chip = snd_pcm_substream_chip(substream);
 
        /* Set restrictions to params. */
-       mutex_lock(&opened_mutex);
+       guard(mutex)(&opened_mutex);
        chip->cur_rate = params_rate(hw_params);
        chip->cur_format = params_format(hw_params);
-       mutex_unlock(&opened_mutex);
 
        return 0;
 }