mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-28 09:22:08 +00:00
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
This commit is contained in:
parent
650224fe8d
commit
3923de04c8
@ -2333,7 +2333,7 @@ static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,
|
|||||||
{
|
{
|
||||||
struct snd_pcm_oss_setup *setup;
|
struct snd_pcm_oss_setup *setup;
|
||||||
|
|
||||||
mutex_lock(&pcm->streams[stream].oss.setup_mutex);
|
guard(mutex)(&pcm->streams[stream].oss.setup_mutex);
|
||||||
do {
|
do {
|
||||||
for (setup = pcm->streams[stream].oss.setup_list; setup;
|
for (setup = pcm->streams[stream].oss.setup_list; setup;
|
||||||
setup = setup->next) {
|
setup = setup->next) {
|
||||||
@ -2344,7 +2344,6 @@ static void snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream,
|
|||||||
out:
|
out:
|
||||||
if (setup)
|
if (setup)
|
||||||
*rsetup = *setup;
|
*rsetup = *setup;
|
||||||
mutex_unlock(&pcm->streams[stream].oss.setup_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream)
|
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_str *pstr = entry->private_data;
|
||||||
struct snd_pcm_oss_setup *setup = pstr->oss.setup_list;
|
struct snd_pcm_oss_setup *setup = pstr->oss.setup_list;
|
||||||
mutex_lock(&pstr->oss.setup_mutex);
|
guard(mutex)(&pstr->oss.setup_mutex);
|
||||||
while (setup) {
|
while (setup) {
|
||||||
snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n",
|
snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n",
|
||||||
setup->task_name,
|
setup->task_name,
|
||||||
@ -2964,7 +2963,6 @@ static void snd_pcm_oss_proc_read(struct snd_info_entry *entry,
|
|||||||
setup->nosilence ? " no-silence" : "");
|
setup->nosilence ? " no-silence" : "");
|
||||||
setup = setup->next;
|
setup = setup->next;
|
||||||
}
|
}
|
||||||
mutex_unlock(&pstr->oss.setup_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr)
|
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;
|
struct snd_pcm_oss_setup *setup, *setup1, template;
|
||||||
|
|
||||||
while (!snd_info_get_line(buffer, line, sizeof(line))) {
|
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));
|
memset(&template, 0, sizeof(template));
|
||||||
ptr = snd_info_get_str(task_name, line, sizeof(task_name));
|
ptr = snd_info_get_str(task_name, line, sizeof(task_name));
|
||||||
if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) {
|
if (!strcmp(task_name, "clear") || !strcmp(task_name, "erase")) {
|
||||||
snd_pcm_oss_proc_free_setup_list(pstr);
|
snd_pcm_oss_proc_free_setup_list(pstr);
|
||||||
mutex_unlock(&pstr->oss.setup_mutex);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (setup = pstr->oss.setup_list; setup; setup = setup->next) {
|
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);
|
setup = kmalloc(sizeof(*setup), GFP_KERNEL);
|
||||||
if (! setup) {
|
if (! setup) {
|
||||||
buffer->error = -ENOMEM;
|
buffer->error = -ENOMEM;
|
||||||
mutex_unlock(&pstr->oss.setup_mutex);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pstr->oss.setup_list == NULL)
|
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) {
|
if (! template.task_name) {
|
||||||
kfree(setup);
|
kfree(setup);
|
||||||
buffer->error = -ENOMEM;
|
buffer->error = -ENOMEM;
|
||||||
mutex_unlock(&pstr->oss.setup_mutex);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*setup = template;
|
*setup = template;
|
||||||
mutex_unlock(&pstr->oss.setup_mutex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user