Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: atmel: Use guard() for mutex locks

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

+6 -12
+6 -12
sound/atmel/ac97c.c
··· 88 88 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); 89 89 struct snd_pcm_runtime *runtime = substream->runtime; 90 90 91 - mutex_lock(&opened_mutex); 91 + guard(mutex)(&opened_mutex); 92 92 chip->opened++; 93 93 runtime->hw = atmel_ac97c_hw; 94 94 if (chip->cur_rate) { ··· 97 97 } 98 98 if (chip->cur_format) 99 99 runtime->hw.formats = pcm_format_to_bits(chip->cur_format); 100 - mutex_unlock(&opened_mutex); 101 100 chip->playback_substream = substream; 102 101 return 0; 103 102 } ··· 106 107 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); 107 108 struct snd_pcm_runtime *runtime = substream->runtime; 108 109 109 - mutex_lock(&opened_mutex); 110 + guard(mutex)(&opened_mutex); 110 111 chip->opened++; 111 112 runtime->hw = atmel_ac97c_hw; 112 113 if (chip->cur_rate) { ··· 115 116 } 116 117 if (chip->cur_format) 117 118 runtime->hw.formats = pcm_format_to_bits(chip->cur_format); 118 - mutex_unlock(&opened_mutex); 119 119 chip->capture_substream = substream; 120 120 return 0; 121 121 } ··· 123 125 { 124 126 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); 125 127 126 - mutex_lock(&opened_mutex); 128 + guard(mutex)(&opened_mutex); 127 129 chip->opened--; 128 130 if (!chip->opened) { 129 131 chip->cur_rate = 0; 130 132 chip->cur_format = 0; 131 133 } 132 - mutex_unlock(&opened_mutex); 133 134 134 135 chip->playback_substream = NULL; 135 136 ··· 139 142 { 140 143 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); 141 144 142 - mutex_lock(&opened_mutex); 145 + guard(mutex)(&opened_mutex); 143 146 chip->opened--; 144 147 if (!chip->opened) { 145 148 chip->cur_rate = 0; 146 149 chip->cur_format = 0; 147 150 } 148 - mutex_unlock(&opened_mutex); 149 151 150 152 chip->capture_substream = NULL; 151 153 ··· 157 161 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); 158 162 159 163 /* Set restrictions to params. */ 160 - mutex_lock(&opened_mutex); 164 + guard(mutex)(&opened_mutex); 161 165 chip->cur_rate = params_rate(hw_params); 162 166 chip->cur_format = params_format(hw_params); 163 - mutex_unlock(&opened_mutex); 164 167 165 168 return 0; 166 169 } ··· 170 175 struct atmel_ac97c *chip = snd_pcm_substream_chip(substream); 171 176 172 177 /* Set restrictions to params. */ 173 - mutex_lock(&opened_mutex); 178 + guard(mutex)(&opened_mutex); 174 179 chip->cur_rate = params_rate(hw_params); 175 180 chip->cur_format = params_format(hw_params); 176 - mutex_unlock(&opened_mutex); 177 181 178 182 return 0; 179 183 }