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

ALSA: opl3: 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/20250829150026.6379-4-tiwai@suse.de

+7 -9
+7 -9
sound/drivers/opl3/opl3_seq.c
··· 40 40 int idx; 41 41 struct snd_hwdep *hwdep = opl3->hwdep; 42 42 43 - mutex_lock(&hwdep->open_mutex); 44 - if (hwdep->used) { 45 - mutex_unlock(&hwdep->open_mutex); 46 - return -EBUSY; 43 + scoped_guard(mutex, &hwdep->open_mutex) { 44 + if (hwdep->used) 45 + return -EBUSY; 46 + hwdep->used++; 47 47 } 48 - hwdep->used++; 49 - mutex_unlock(&hwdep->open_mutex); 50 48 51 49 snd_opl3_reset(opl3); 52 50 ··· 79 81 80 82 snd_opl3_reset(opl3); 81 83 hwdep = opl3->hwdep; 82 - mutex_lock(&hwdep->open_mutex); 83 - hwdep->used--; 84 - mutex_unlock(&hwdep->open_mutex); 84 + scoped_guard(mutex, &hwdep->open_mutex) { 85 + hwdep->used--; 86 + } 85 87 wake_up(&hwdep->open_wait); 86 88 } 87 89