mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 11:06:41 -05:00
ALSA: korg1212: 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/20250829144342.4290-38-tiwai@suse.de
This commit is contained in:
@@ -606,13 +606,12 @@ static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
|
||||
{
|
||||
K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n",
|
||||
stateName[korg1212->cardState], korg1212->opencnt);
|
||||
mutex_lock(&korg1212->open_mutex);
|
||||
guard(mutex)(&korg1212->open_mutex);
|
||||
if (korg1212->opencnt++ == 0) {
|
||||
snd_korg1212_TurnOffIdleMonitor(korg1212);
|
||||
snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
|
||||
}
|
||||
|
||||
mutex_unlock(&korg1212->open_mutex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -621,11 +620,9 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
|
||||
K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n",
|
||||
stateName[korg1212->cardState], korg1212->opencnt);
|
||||
|
||||
mutex_lock(&korg1212->open_mutex);
|
||||
if (--(korg1212->opencnt)) {
|
||||
mutex_unlock(&korg1212->open_mutex);
|
||||
guard(mutex)(&korg1212->open_mutex);
|
||||
if (--(korg1212->opencnt))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (korg1212->cardState == K1212_STATE_SETUP) {
|
||||
int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
|
||||
@@ -633,10 +630,8 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
|
||||
if (rc)
|
||||
K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n",
|
||||
rc, stateName[korg1212->cardState]);
|
||||
if (rc != K1212_CMDRET_Success) {
|
||||
mutex_unlock(&korg1212->open_mutex);
|
||||
if (rc != K1212_CMDRET_Success)
|
||||
return 0;
|
||||
}
|
||||
} else if (korg1212->cardState > K1212_STATE_SETUP) {
|
||||
snd_korg1212_SendStopAndWait(korg1212);
|
||||
}
|
||||
@@ -646,7 +641,6 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
|
||||
snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
|
||||
}
|
||||
|
||||
mutex_unlock(&korg1212->open_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user