mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02: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
					
				
					 1 changed files with 3 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue