diff options
| -rw-r--r-- | hcid/adapter.c | 10 | ||||
| -rw-r--r-- | hcid/dbus-hci.c | 2 | ||||
| -rw-r--r-- | hcid/device.c | 8 | ||||
| -rw-r--r-- | hcid/device.h | 1 | 
4 files changed, 17 insertions, 4 deletions
| diff --git a/hcid/adapter.c b/hcid/adapter.c index 753a1c47..15209333 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -257,7 +257,7 @@ static void device_agent_removed(struct agent *agent, void *user_data)  	struct adapter *adapter;  	adapter = device_get_adapter(device); -	device->agent = NULL; +	device_set_agent(device, NULL);  	l = g_slist_find_custom(adapter->auth_reqs, agent,  					auth_info_agent_cmp); @@ -279,6 +279,7 @@ static struct bonding_request_info *bonding_request_new(DBusConnection *conn,  	struct device *device;  	const char *name = dbus_message_get_sender(msg);  	const gchar *destination; +	struct agent *agent;  	debug("bonding_request_new(%s)", address); @@ -287,10 +288,13 @@ static struct bonding_request_info *bonding_request_new(DBusConnection *conn,  		return NULL;  	destination = device_get_address(device); -	device->agent = agent_create(adapter, name, agent_path, +	agent = agent_create(adapter, name, agent_path,  					capability,  					device_agent_removed,  					device); + +	device_set_agent(device, agent); +  	debug("Temporary agent registered for hci%d/%s at %s:%s",  			adapter->dev_id, destination, name,  			agent_path); @@ -765,7 +769,7 @@ void adapter_remove_device(DBusConnection *conn, struct adapter *adapter,  	if (agent) {  		agent_destroy(agent, FALSE); -		device->agent = NULL; +		device_set_agent(device, NULL);  	}  	adapter->devices = g_slist_remove(adapter->devices, device); diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index 3af3f046..61d64c19 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -83,7 +83,7 @@ void bonding_request_free(struct bonding_request_info *bonding)  	if (device && agent) {  		agent_destroy(agent, FALSE); -		device->agent = NULL; +		device_set_agent(device, NULL);  	}  	g_free(bonding); diff --git a/hcid/device.c b/hcid/device.c index 87f9d80c..06c5db4f 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -960,6 +960,14 @@ struct agent *device_get_agent(struct device *device)  	return  device->agent;  } +void device_set_agent(struct device *device, struct agent *agent) +{ +	if (!device) +		return; + +	device->agent = agent; +} +  int btd_register_device_driver(struct btd_device_driver *driver)  {  	const char **uuid; diff --git a/hcid/device.h b/hcid/device.h index 611b8140..038e9764 100644 --- a/hcid/device.h +++ b/hcid/device.h @@ -60,6 +60,7 @@ struct adapter *device_get_adapter(struct device *device);  const gchar *device_get_address(struct device *device);  const gchar *device_get_path(struct device *device);  struct agent *device_get_agent(struct device *device); +void device_set_agent(struct device *device, struct agent *agent);  #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) | 
