mirror of
				https://git.kernel.org/pub/scm/network/wireless/iwd.git
				synced 2025-11-04 08:57:29 +01:00 
			
		
		
		
	device: command: remove default device concept
There was quite a bit of framework behind setting/resetting a default device, which is now no longer needed.
This commit is contained in:
		
							parent
							
								
									fce1bb60a8
								
							
						
					
					
						commit
						69e9945ef7
					
				@ -329,9 +329,6 @@ static char **cmd_completion_match_family_cmd(const char *cmd_family,
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (family->set_default_entity)
 | 
			
		||||
			family->set_default_entity(arg1);
 | 
			
		||||
 | 
			
		||||
		matches = cmd_completion_match_entity_cmd(arg2, text,
 | 
			
		||||
							family->command_list);
 | 
			
		||||
 | 
			
		||||
@ -663,21 +660,6 @@ int command_get_exit_status(void)
 | 
			
		||||
	return exit_status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void command_reset_default_entities(void)
 | 
			
		||||
{
 | 
			
		||||
	const struct l_queue_entry *entry;
 | 
			
		||||
 | 
			
		||||
	for (entry = l_queue_get_entries(command_families); entry;
 | 
			
		||||
							entry = entry->next) {
 | 
			
		||||
		struct command_family *family = entry->data;
 | 
			
		||||
 | 
			
		||||
		if (!family->reset_default_entity)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		family->reset_default_entity();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void command_family_register(const struct command_family *family)
 | 
			
		||||
{
 | 
			
		||||
	l_queue_push_tail(command_families, (void *) family);
 | 
			
		||||
 | 
			
		||||
@ -56,8 +56,6 @@ struct command_family {
 | 
			
		||||
	const struct command *command_list;
 | 
			
		||||
	command_rl_completion_func_t family_arg_completion;
 | 
			
		||||
	command_rl_completion_func_t entity_arg_completion;
 | 
			
		||||
	void (*set_default_entity)(const char *entity);
 | 
			
		||||
	void (*reset_default_entity)(void);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool command_option_get(const char *name, const char **value_out);
 | 
			
		||||
@ -74,7 +72,6 @@ void command_noninteractive_trigger(void);
 | 
			
		||||
bool command_is_interactive_mode(void);
 | 
			
		||||
int command_get_exit_status(void);
 | 
			
		||||
void command_set_exit_status(int status);
 | 
			
		||||
void command_reset_default_entities(void);
 | 
			
		||||
 | 
			
		||||
void command_family_register(const struct command_family *family);
 | 
			
		||||
void command_family_unregister(const struct command_family *family);
 | 
			
		||||
 | 
			
		||||
@ -806,8 +806,6 @@ static void service_disappeared_callback(struct l_dbus *dbus,
 | 
			
		||||
 | 
			
		||||
	l_queue_clear(proxy_interfaces, proxy_interface_destroy);
 | 
			
		||||
 | 
			
		||||
	command_reset_default_entities();
 | 
			
		||||
 | 
			
		||||
	display_disable_cmd_prompt();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -42,8 +42,6 @@ struct device {
 | 
			
		||||
	const struct proxy_interface *adapter;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct proxy_interface *default_device;
 | 
			
		||||
 | 
			
		||||
static void display_device(const struct proxy_interface *proxy)
 | 
			
		||||
{
 | 
			
		||||
	const struct device *device = proxy_interface_get_data(proxy);
 | 
			
		||||
@ -260,52 +258,6 @@ static bool match_by_partial_name(const void *a, const void *b)
 | 
			
		||||
	return !strncmp(device->name, text, strlen(text));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool match_all(const void *a, const void *b)
 | 
			
		||||
{
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void device_set_default(const char *device_name)
 | 
			
		||||
{
 | 
			
		||||
	struct l_queue *match;
 | 
			
		||||
 | 
			
		||||
	if (!device_name)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	match = proxy_interface_find_all(device_interface_type.interface,
 | 
			
		||||
						match_by_name, device_name);
 | 
			
		||||
 | 
			
		||||
	if (!match)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	default_device = l_queue_pop_head(match);
 | 
			
		||||
	l_queue_destroy(match, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void device_reset_default(void)
 | 
			
		||||
{
 | 
			
		||||
	default_device = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const struct proxy_interface *device_get_default(void)
 | 
			
		||||
{
 | 
			
		||||
	struct l_queue *match;
 | 
			
		||||
 | 
			
		||||
	if (default_device)
 | 
			
		||||
		return default_device;
 | 
			
		||||
 | 
			
		||||
	match = proxy_interface_find_all(device_interface_type.interface,
 | 
			
		||||
							match_all, NULL);
 | 
			
		||||
 | 
			
		||||
	if (!match)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	default_device = l_queue_pop_head(match);
 | 
			
		||||
	l_queue_destroy(match, NULL);
 | 
			
		||||
 | 
			
		||||
	return default_device;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const struct proxy_interface *device_proxy_find_by_name(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	struct l_queue *match;
 | 
			
		||||
@ -464,8 +416,6 @@ static struct command_family device_command_family = {
 | 
			
		||||
	.command_list = device_commands,
 | 
			
		||||
	.family_arg_completion = family_arg_completion,
 | 
			
		||||
	.entity_arg_completion = entity_arg_completion,
 | 
			
		||||
	.set_default_entity = device_set_default,
 | 
			
		||||
	.reset_default_entity = device_reset_default,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int device_command_family_init(void)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user