From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH 23/24] ALSA: pcm: oss: Use guard() for setup
Date: Fri, 23 Feb 2024 17:28:09 +0100 [thread overview]
Message-ID: <20240223162810.32302-24-tiwai@suse.de> (raw)
In-Reply-To: <20240223162810.32302-1-tiwai@suse.de>
The setup_mutex in PCM oss code can be simplified with guard().
(params_lock is tough and not trivial to covert, though.)
Only the code refactoring, and no functional changes.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/oss/pcm_oss.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 49ea092e90f9..7386982cf40e 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2333,7 +2333,7 @@ static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,
{
struct snd_pcm_oss_setup *setup;
- mutex_lock(&pcm->streams[stream].oss.setup_mutex);
+ guard(mutex)(&pcm->streams[stream].oss.setup_mutex);
do {
for (setup = pcm->streams[stream].oss.setup_list; setup;
setup = setup->next) {
@@ -2344,7 +2344,6 @@ static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,
out:
if (setup)
*rsetup = *setup;
- mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
}
static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream)
@@ -2950,7 +2949,7 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
{
struct snd_pcm_str *pstr = entry->private_data;
struct snd_pcm_oss_setup *setup = pstr->oss.setup_list;
- mutex_lock(&pstr->oss.setup_mutex);
+ guard(mutex)(&pstr->oss.setup_mutex);
while (setup) {
snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n",
setup->task_name,
@@ -2964,7 +2963,6 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
setup->nosilence ? " no-silence" : "");
setup = setup->next;
}
- mutex_unlock(&pstr->oss.setup_mutex);
}
static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr)
@@ -2990,12 +2988,11 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
struct snd_pcm_oss_setup *setup, *setup1, template;
while (!snd_info_get_line(buffer, line, sizeof(line))) {
- mutex_lock(&pstr->oss.setup_mutex);
+ guard(mutex)(&pstr->oss.setup_mutex);
memset(&template, 0, sizeof(template));
ptr = snd_info_get_str(task_name, line, sizeof(task_name));
if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) {
snd_pcm_oss_proc_free_setup_list(pstr);
- mutex_unlock(&pstr->oss.setup_mutex);
continue;
}
for (setup = pstr->oss.setup_list; setup; setup = setup->next) {
@@ -3035,7 +3032,6 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
setup = kmalloc(sizeof(*setup), GFP_KERNEL);
if (! setup) {
buffer->error = -ENOMEM;
- mutex_unlock(&pstr->oss.setup_mutex);
return;
}
if (pstr->oss.setup_list == NULL)
@@ -3049,12 +3045,10 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
if (! template.task_name) {
kfree(setup);
buffer->error = -ENOMEM;
- mutex_unlock(&pstr->oss.setup_mutex);
return;
}
}
*setup = template;
- mutex_unlock(&pstr->oss.setup_mutex);
}
}
--
2.35.3
next prev parent reply other threads:[~2024-02-23 16:28 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 16:27 [PATCH 00/24] Clean up locking with guard() in ALSA core Takashi Iwai
2024-02-23 16:27 ` [PATCH 01/24] ALSA: ump: Use guard() for locking Takashi Iwai
2024-02-23 16:27 ` [PATCH 02/24] ALSA: compress_offload: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 03/24] ALSA: timer: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 04/24] ALSA: hrtimer: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 05/24] ALSA: hwdep: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 06/24] ALSA: info: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 07/24] ALSA: mixer_oss: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 08/24] ALSA: control: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 09/24] ALSA: rawmidi: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 10/24] ALSA: jack: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 11/24] ALSA: core: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 12/24] ALSA: seq: fifo: " Takashi Iwai
2024-02-23 16:27 ` [PATCH 13/24] ALSA: seq: memory: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 14/24] ALSA: seq: ports: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 15/24] ALSA: seq: queue: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 16/24] ALSA: seq: timer: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 17/24] ALSA: seq: midi: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 18/24] ALSA: seq: ump: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 19/24] ALSA: seq: virmidi: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 20/24] ALSA: seq: prioq: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 21/24] ALSA: pcm: " Takashi Iwai
2024-02-23 16:28 ` [PATCH 22/24] ALSA: pcm: Use guard() for PCM stream locks Takashi Iwai
2024-02-23 16:28 ` Takashi Iwai [this message]
2024-02-23 16:28 ` [PATCH 24/24] ALSA: control_led: Use guard() for locking 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=20240223162810.32302-24-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