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

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: sparc: 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-13-tiwai@suse.de

+6 -15
+6 -15
sound/sparc/cs4231.c
··· 608 608 { 609 609 unsigned long flags; 610 610 611 - mutex_lock(&chip->mce_mutex); 611 + guard(mutex)(&chip->mce_mutex); 612 612 snd_cs4231_calibrate_mute(chip, 1); 613 613 614 614 snd_cs4231_mce_up(chip); ··· 623 623 snd_cs4231_mce_down(chip); 624 624 625 625 snd_cs4231_calibrate_mute(chip, 0); 626 - mutex_unlock(&chip->mce_mutex); 627 626 } 628 627 629 628 static void snd_cs4231_capture_format(struct snd_cs4231 *chip, ··· 631 632 { 632 633 unsigned long flags; 633 634 634 - mutex_lock(&chip->mce_mutex); 635 + guard(mutex)(&chip->mce_mutex); 635 636 snd_cs4231_calibrate_mute(chip, 1); 636 637 637 638 snd_cs4231_mce_up(chip); ··· 652 653 snd_cs4231_mce_down(chip); 653 654 654 655 snd_cs4231_calibrate_mute(chip, 0); 655 - mutex_unlock(&chip->mce_mutex); 656 656 } 657 657 658 658 /* ··· 773 775 { 774 776 unsigned long flags; 775 777 776 - mutex_lock(&chip->open_mutex); 777 - if ((chip->mode & mode)) { 778 - mutex_unlock(&chip->open_mutex); 778 + guard(mutex)(&chip->open_mutex); 779 + if ((chip->mode & mode)) 779 780 return -EAGAIN; 780 - } 781 781 if (chip->mode & CS4231_MODE_OPEN) { 782 782 chip->mode |= mode; 783 - mutex_unlock(&chip->open_mutex); 784 783 return 0; 785 784 } 786 785 /* ok. now enable and ack CODEC IRQ */ ··· 797 802 spin_unlock_irqrestore(&chip->lock, flags); 798 803 799 804 chip->mode = mode; 800 - mutex_unlock(&chip->open_mutex); 801 805 return 0; 802 806 } 803 807 ··· 804 810 { 805 811 unsigned long flags; 806 812 807 - mutex_lock(&chip->open_mutex); 813 + guard(mutex)(&chip->open_mutex); 808 814 chip->mode &= ~mode; 809 - if (chip->mode & CS4231_MODE_OPEN) { 810 - mutex_unlock(&chip->open_mutex); 815 + if (chip->mode & CS4231_MODE_OPEN) 811 816 return; 812 - } 813 817 snd_cs4231_calibrate_mute(chip, 1); 814 818 815 819 /* disable IRQ */ ··· 843 851 snd_cs4231_calibrate_mute(chip, 0); 844 852 845 853 chip->mode = 0; 846 - mutex_unlock(&chip->open_mutex); 847 854 } 848 855 849 856 /*