mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	ucm: add a check for the empty configuration
Return an error if the UCM configuration is empty (no verbs or no boot sequence). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
		
							parent
							
								
									e80f35611d
								
							
						
					
					
						commit
						22d5ca8b6b
					
				
					 1 changed files with 23 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -568,6 +568,20 @@ static int import_master_config(snd_use_case_mgr_t *uc_mgr)
 | 
			
		|||
	return add_auto_values(uc_mgr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief Check, if the UCM configuration is empty
 | 
			
		||||
 * \param uc_mgr Use case Manager
 | 
			
		||||
 * \return zero on success, otherwise a negative error code
 | 
			
		||||
 */
 | 
			
		||||
static int check_empty_configuration(snd_use_case_mgr_t *uc_mgr)
 | 
			
		||||
{
 | 
			
		||||
	if (!list_empty(&uc_mgr->verb_list))
 | 
			
		||||
		return 0;
 | 
			
		||||
	if (!list_empty(&uc_mgr->once_list))
 | 
			
		||||
		return 0;
 | 
			
		||||
	return -ENXIO;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief Universal find - string in a list
 | 
			
		||||
 * \param list List of structures
 | 
			
		||||
| 
						 | 
				
			
			@ -981,14 +995,20 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
 | 
			
		|||
	err = import_master_config(mgr);
 | 
			
		||||
	if (err < 0) {
 | 
			
		||||
		uc_error("error: failed to import %s use case configuration %d",
 | 
			
		||||
			card_name, err);
 | 
			
		||||
		goto err;
 | 
			
		||||
			 card_name, err);
 | 
			
		||||
		goto _err;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = check_empty_configuration(mgr);
 | 
			
		||||
	if (err < 0) {
 | 
			
		||||
		uc_error("error: failed to import %s (empty configuration)", card_name);
 | 
			
		||||
		goto _err;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*uc_mgr = mgr;
 | 
			
		||||
	return 0;
 | 
			
		||||
 | 
			
		||||
err:
 | 
			
		||||
_err:
 | 
			
		||||
	uc_mgr_free(mgr);
 | 
			
		||||
	return err;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue