From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH 03/13] ALSA: opl3: Use guard() for mutex locks
Date: Fri, 29 Aug 2025 17:00:14 +0200 [thread overview]
Message-ID: <20250829150026.6379-4-tiwai@suse.de> (raw)
In-Reply-To: <20250829150026.6379-1-tiwai@suse.de>
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>
---
sound/drivers/opl3/opl3_seq.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c
index 9fc78b7fb780..8db77a81476c 100644
--- a/sound/drivers/opl3/opl3_seq.c
+++ b/sound/drivers/opl3/opl3_seq.c
@@ -40,13 +40,11 @@ int snd_opl3_synth_setup(struct snd_opl3 * opl3)
int idx;
struct snd_hwdep *hwdep = opl3->hwdep;
- mutex_lock(&hwdep->open_mutex);
- if (hwdep->used) {
- mutex_unlock(&hwdep->open_mutex);
- return -EBUSY;
+ scoped_guard(mutex, &hwdep->open_mutex) {
+ if (hwdep->used)
+ return -EBUSY;
+ hwdep->used++;
}
- hwdep->used++;
- mutex_unlock(&hwdep->open_mutex);
snd_opl3_reset(opl3);
@@ -81,9 +79,9 @@ void snd_opl3_synth_cleanup(struct snd_opl3 * opl3)
snd_opl3_reset(opl3);
hwdep = opl3->hwdep;
- mutex_lock(&hwdep->open_mutex);
- hwdep->used--;
- mutex_unlock(&hwdep->open_mutex);
+ scoped_guard(mutex, &hwdep->open_mutex) {
+ hwdep->used--;
+ }
wake_up(&hwdep->open_wait);
}
--
2.50.1
next prev parent reply other threads:[~2025-08-29 15:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 15:00 [PATCH 00/13] ALSA: Use auto-cleanup macros for generic drivers Takashi Iwai
2025-08-29 15:00 ` [PATCH 01/13] ALSA: aloop: Use guard() for mutex locks Takashi Iwai
2025-08-29 15:00 ` [PATCH 02/13] ALSA: aloop: Use guard() for spin locks Takashi Iwai
2025-08-29 15:00 ` Takashi Iwai [this message]
2025-08-29 15:00 ` [PATCH 04/13] ALSA: opl3: " Takashi Iwai
2025-08-29 15:00 ` [PATCH 05/13] ALSA: opl4: Use guard() for mutex locks Takashi Iwai
2025-08-29 15:00 ` [PATCH 06/13] ALSA: opl4: Use guard() for spin locks Takashi Iwai
2025-08-29 15:00 ` [PATCH 07/13] ALSA: vx: Use guard() for mutex locks Takashi Iwai
2025-08-29 15:00 ` [PATCH 08/13] ALSA: dummy: Use guard() for spin locks Takashi Iwai
2025-08-29 15:00 ` [PATCH 09/13] ALSA: mpu401: " Takashi Iwai
2025-08-29 15:00 ` [PATCH 10/13] ALSA: mtpav: " Takashi Iwai
2025-08-29 15:00 ` [PATCH 11/13] ALSA: mts64: " Takashi Iwai
2025-08-29 15:00 ` [PATCH 12/13] ALSA: portman2x4: " Takashi Iwai
2025-08-29 15:00 ` [PATCH 13/13] ALSA: serial-u16550: " Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250829150026.6379-4-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-sound@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).