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

ALSA: seq: oss: Clean up core code with guard()

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/20250827080520.7544-9-tiwai@suse.de

+7 -17
+7 -17
sound/core/seq/oss/seq_oss.c
··· 117 117 static int 118 118 odev_open(struct inode *inode, struct file *file) 119 119 { 120 - int level, rc; 120 + int level; 121 121 122 122 if (iminor(inode) == SNDRV_MINOR_OSS_MUSIC) 123 123 level = SNDRV_SEQ_OSS_MODE_MUSIC; 124 124 else 125 125 level = SNDRV_SEQ_OSS_MODE_SYNTH; 126 126 127 - mutex_lock(&register_mutex); 128 - rc = snd_seq_oss_open(file, level); 129 - mutex_unlock(&register_mutex); 130 - 131 - return rc; 127 + guard(mutex)(&register_mutex); 128 + return snd_seq_oss_open(file, level); 132 129 } 133 130 134 131 static int ··· 137 140 if (!dp) 138 141 return 0; 139 142 140 - mutex_lock(&register_mutex); 143 + guard(mutex)(&register_mutex); 141 144 snd_seq_oss_release(dp); 142 - mutex_unlock(&register_mutex); 143 - 144 145 return 0; 145 146 } 146 147 ··· 224 229 { 225 230 int rc; 226 231 227 - mutex_lock(&register_mutex); 232 + guard(mutex)(&register_mutex); 228 233 rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, 229 234 NULL, 0, 230 235 &seq_oss_f_ops, NULL); 231 236 if (rc < 0) { 232 237 pr_err("ALSA: seq_oss: can't register device seq\n"); 233 - mutex_unlock(&register_mutex); 234 238 return rc; 235 239 } 236 240 rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, ··· 238 244 if (rc < 0) { 239 245 pr_err("ALSA: seq_oss: can't register device music\n"); 240 246 snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); 241 - mutex_unlock(&register_mutex); 242 247 return rc; 243 248 } 244 - mutex_unlock(&register_mutex); 245 249 return 0; 246 250 } 247 251 248 252 static void 249 253 unregister_device(void) 250 254 { 251 - mutex_lock(&register_mutex); 255 + guard(mutex)(&register_mutex); 252 256 if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0) < 0) 253 257 pr_err("ALSA: seq_oss: error unregister device music\n"); 254 258 if (snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0) < 0) 255 259 pr_err("ALSA: seq_oss: error unregister device seq\n"); 256 - mutex_unlock(&register_mutex); 257 260 } 258 261 259 262 /* ··· 264 273 static void 265 274 info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) 266 275 { 267 - mutex_lock(&register_mutex); 276 + guard(mutex)(&register_mutex); 268 277 snd_iprintf(buf, "OSS sequencer emulation version %s\n", SNDRV_SEQ_OSS_VERSION_STR); 269 278 snd_seq_oss_system_info_read(buf); 270 279 snd_seq_oss_synth_info_read(buf); 271 280 snd_seq_oss_midi_info_read(buf); 272 - mutex_unlock(&register_mutex); 273 281 } 274 282 275 283