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

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

+4 -10
+4 -10
sound/pci/korg1212/korg1212.c
··· 606 606 { 607 607 K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", 608 608 stateName[korg1212->cardState], korg1212->opencnt); 609 - mutex_lock(&korg1212->open_mutex); 609 + guard(mutex)(&korg1212->open_mutex); 610 610 if (korg1212->opencnt++ == 0) { 611 611 snd_korg1212_TurnOffIdleMonitor(korg1212); 612 612 snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); 613 613 } 614 614 615 - mutex_unlock(&korg1212->open_mutex); 616 615 return 1; 617 616 } 618 617 ··· 620 621 K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", 621 622 stateName[korg1212->cardState], korg1212->opencnt); 622 623 623 - mutex_lock(&korg1212->open_mutex); 624 - if (--(korg1212->opencnt)) { 625 - mutex_unlock(&korg1212->open_mutex); 624 + guard(mutex)(&korg1212->open_mutex); 625 + if (--(korg1212->opencnt)) 626 626 return 0; 627 - } 628 627 629 628 if (korg1212->cardState == K1212_STATE_SETUP) { 630 629 int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, ··· 630 633 if (rc) 631 634 K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", 632 635 rc, stateName[korg1212->cardState]); 633 - if (rc != K1212_CMDRET_Success) { 634 - mutex_unlock(&korg1212->open_mutex); 636 + if (rc != K1212_CMDRET_Success) 635 637 return 0; 636 - } 637 638 } else if (korg1212->cardState > K1212_STATE_SETUP) { 638 639 snd_korg1212_SendStopAndWait(korg1212); 639 640 } ··· 641 646 snd_korg1212_setCardState(korg1212, K1212_STATE_READY); 642 647 } 643 648 644 - mutex_unlock(&korg1212->open_mutex); 645 649 return 0; 646 650 } 647 651