Skip to content

Commit 3923de0

Browse files
committed
ALSA: pcm: oss: Use guard() for setup
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> Link: https://lore.kernel.org/r/20240227085306.9764-24-tiwai@suse.de
1 parent 650224f commit 3923de0

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

sound/core/oss/pcm_oss.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,7 +2333,7 @@ static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,
23332333
{
23342334
struct snd_pcm_oss_setup *setup;
23352335

2336-
mutex_lock(&pcm->streams[stream].oss.setup_mutex);
2336+
guard(mutex)(&pcm->streams[stream].oss.setup_mutex);
23372337
do {
23382338
for (setup = pcm->streams[stream].oss.setup_list; setup;
23392339
setup = setup->next) {
@@ -2344,7 +2344,6 @@ static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,
23442344
out:
23452345
if (setup)
23462346
*rsetup = *setup;
2347-
mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
23482347
}
23492348

23502349
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,
29502949
{
29512950
struct snd_pcm_str *pstr = entry->private_data;
29522951
struct snd_pcm_oss_setup *setup = pstr->oss.setup_list;
2953-
mutex_lock(&pstr->oss.setup_mutex);
2952+
guard(mutex)(&pstr->oss.setup_mutex);
29542953
while (setup) {
29552954
snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n",
29562955
setup->task_name,
@@ -2964,7 +2963,6 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
29642963
setup->nosilence ? " no-silence" : "");
29652964
setup = setup->next;
29662965
}
2967-
mutex_unlock(&pstr->oss.setup_mutex);
29682966
}
29692967

29702968
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,
29902988
struct snd_pcm_oss_setup *setup, *setup1, template;
29912989

29922990
while (!snd_info_get_line(buffer, line, sizeof(line))) {
2993-
mutex_lock(&pstr->oss.setup_mutex);
2991+
guard(mutex)(&pstr->oss.setup_mutex);
29942992
memset(&template, 0, sizeof(template));
29952993
ptr = snd_info_get_str(task_name, line, sizeof(task_name));
29962994
if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) {
29972995
snd_pcm_oss_proc_free_setup_list(pstr);
2998-
mutex_unlock(&pstr->oss.setup_mutex);
29992996
continue;
30002997
}
30012998
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,
30353032
setup = kmalloc(sizeof(*setup), GFP_KERNEL);
30363033
if (! setup) {
30373034
buffer->error = -ENOMEM;
3038-
mutex_unlock(&pstr->oss.setup_mutex);
30393035
return;
30403036
}
30413037
if (pstr->oss.setup_list == NULL)
@@ -3049,12 +3045,10 @@ static void snd_pcm_oss_proc_write(struct snd_info_entry *entry,
30493045
if (! template.task_name) {
30503046
kfree(setup);
30513047
buffer->error = -ENOMEM;
3052-
mutex_unlock(&pstr->oss.setup_mutex);
30533048
return;
30543049
}
30553050
}
30563051
*setup = template;
3057-
mutex_unlock(&pstr->oss.setup_mutex);
30583052
}
30593053
}
30603054

0 commit comments

Comments
 (0)