diff options
| author | Alok Barsode <alok.barsode@azingo.com> | 2008-07-21 19:46:42 +0530 | 
|---|---|---|
| committer | Luiz Augusto von Dentz <luiz.dentz@indt.org.br> | 2008-07-28 10:47:58 -0300 | 
| commit | b76fbc7d29f28a95a9ea25aae1f6f2d9c10adb19 (patch) | |
| tree | c9fa8e8e8f8f0fe6b22980d7fcca9f102e9c3628 | |
| parent | 473e0415d60fd1c067d3a2741a13424b8b06bae1 (diff) | |
Adding {driver, priv} list to btd_device and adding
driver as parameter to probe and remove.
Signed-off-by: Alok Barsode <alok.barsode@azingo.com>
| -rw-r--r-- | audio/main.c | 18 | ||||
| -rw-r--r-- | hcid/device.c | 32 | ||||
| -rw-r--r-- | hcid/device.h | 6 | ||||
| -rw-r--r-- | input/manager.c | 12 | ||||
| -rw-r--r-- | network/manager.c | 18 | ||||
| -rw-r--r-- | serial/main.c | 6 | 
6 files changed, 64 insertions, 28 deletions
| diff --git a/audio/main.c b/audio/main.c index 8e4c8055..f0301c12 100644 --- a/audio/main.c +++ b/audio/main.c @@ -43,7 +43,8 @@  static DBusConnection *conn; -static int headset_probe(struct btd_device *device, GSList *records) +static int headset_probe(struct btd_device_driver *driver, +			struct btd_device *device, GSList *records)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); @@ -51,7 +52,8 @@ static int headset_probe(struct btd_device *device, GSList *records)  	return 0;  } -static void headset_remove(struct btd_device *device) +static void headset_remove(struct btd_device_driver *driver, +				struct btd_device *device)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); @@ -64,7 +66,8 @@ static struct btd_device_driver headset_driver = {  	.remove	= headset_remove,  }; -static int a2dp_probe(struct btd_device *device, GSList *records) +static int a2dp_probe(struct btd_device_driver *driver, +			struct btd_device *device, GSList *records)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); @@ -72,7 +75,8 @@ static int a2dp_probe(struct btd_device *device, GSList *records)  	return 0;  } -static void a2dp_remove(struct btd_device *device) +static void a2dp_remove(struct btd_device_driver *driver, +				struct btd_device *device)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); @@ -85,7 +89,8 @@ static struct btd_device_driver a2dp_driver = {  	.remove	= a2dp_remove,  }; -static int audio_probe(struct btd_device *device, GSList *records) +static int audio_probe(struct btd_device_driver *driver, +			struct btd_device *device, GSList *records)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); @@ -93,7 +98,8 @@ static int audio_probe(struct btd_device *device, GSList *records)  	return 0;  } -static void audio_remove(struct btd_device *device) +static void audio_remove(struct btd_device_driver *driver, +				struct btd_device *device)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); diff --git a/hcid/device.c b/hcid/device.c index cfbab920..f83801a4 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -68,12 +68,17 @@  #define DEVICE_INTERFACE "org.bluez.Device" +static struct btd_driver_data { +	struct btd_device_driver *driver; +	void *priv; +}; +  struct btd_device {  	gchar		*address;  	gchar		*path;  	struct adapter	*adapter;  	GSList		*uuids; -	GSList		*drivers; +	GSList		*drivers;		/* List of driver_data */  	gboolean	temporary;  	struct agent	*agent;  	guint		disconn_timer; @@ -557,9 +562,11 @@ void device_remove(DBusConnection *conn, struct btd_device *device)  	debug("Removing device %s", path);  	for (list = device->drivers; list; list = list->next) { -		driver = (struct btd_device_driver *) list->data; +		struct btd_driver_data *driver_data = list->data; +		driver = driver_data->driver; -		driver->remove(device); +		driver->remove(driver, device); +		g_free(driver_data);  	}  	g_dbus_unregister_interface(conn, path, DEVICE_INTERFACE); @@ -623,15 +630,20 @@ void device_probe_drivers(struct btd_device *device, GSList *uuids, sdp_list_t *  		}  		if (records) { -			err = driver->probe(device, records); +			struct btd_driver_data *driver_data = g_new0(struct btd_driver_data, 1); + +			err = driver->probe(driver, device, records);  			if (err < 0) {  				error("probe failed for driver %s",  							driver->name); + +				g_free(driver_data);  				continue;  			} +			driver_data->driver = driver;  			device->drivers = g_slist_append(device->drivers, -								driver); +								driver_data);  		}  	} @@ -650,7 +662,8 @@ void device_remove_drivers(struct btd_device *device, GSList *uuids, sdp_list_t  	debug("Remove drivers for %s", device->path);  	for (list = device->drivers; list; list = list->next) { -		struct btd_device_driver *driver = list->data; +		struct btd_driver_data *driver_data = list->data; +		struct btd_device_driver *driver = driver_data->driver;  		const char **uuid;  		for (uuid = driver->uuids; *uuid; uuid++) { @@ -660,9 +673,12 @@ void device_remove_drivers(struct btd_device *device, GSList *uuids, sdp_list_t  			if (!match)  				continue; -			driver->remove(device); +			driver->remove(driver, device);  			device->drivers = g_slist_remove(device->drivers, -								driver); +								driver_data); + +			g_free(driver_data); +  			sdp_record_t *rec = get_record(recs, *uuid);  			delete_record(src, dst, rec->handle);  		} diff --git a/hcid/device.h b/hcid/device.h index bbb0846f..31480a66 100644 --- a/hcid/device.h +++ b/hcid/device.h @@ -48,8 +48,10 @@ uint8_t device_get_auth(struct btd_device *device);  struct btd_device_driver {  	const char *name;  	const char **uuids; -	int (*probe) (struct btd_device *device, GSList *records); -	void (*remove) (struct btd_device *device); +	int (*probe) (struct btd_device_driver *driver, +			struct btd_device *device, GSList *records); +	void (*remove) (struct btd_device_driver *driver, +			struct btd_device *device);  };  int btd_register_device_driver(struct btd_device_driver *driver); diff --git a/input/manager.c b/input/manager.c index dc7440cd..aaa4a3ba 100644 --- a/input/manager.c +++ b/input/manager.c @@ -162,7 +162,8 @@ static int load_stored(const char *source, const char *destination,  	return parse_stored_device_info(value, hidp);  } -int input_probe(struct btd_device *device, GSList *records) +int input_probe(struct btd_device_driver *driver, +		struct btd_device *device, GSList *records)  {  	struct adapter *adapter = device_get_adapter(device);  	const gchar *path = device_get_path(device); @@ -196,7 +197,8 @@ done:  	return input_device_register(connection, &src, &dst, &hidp, path);  } -void input_remove(struct btd_device *device) +void input_remove(struct btd_device_driver *driver, +			struct btd_device *device)  {  	const gchar *path = device_get_path(device); @@ -205,7 +207,8 @@ void input_remove(struct btd_device *device)  	input_device_unregister(connection, path);  } -int headset_input_probe(struct btd_device *device, GSList *records) +int headset_input_probe(struct btd_device_driver *driver, +			struct btd_device *device, GSList *records)  {  	struct adapter *adapter = device_get_adapter(device);  	const gchar *path = device_get_path(device); @@ -240,7 +243,8 @@ int headset_input_probe(struct btd_device *device, GSList *records)  	return fake_input_register(connection, &src, &dst, ch, path);  } -void headset_input_remove(struct btd_device *device) +void headset_input_remove(struct btd_device_driver *driver, +				struct btd_device *device)  {  	const gchar *path = device_get_path(device); diff --git a/network/manager.c b/network/manager.c index 27573101..616d63c0 100644 --- a/network/manager.c +++ b/network/manager.c @@ -98,17 +98,20 @@ static int network_probe(struct btd_device *device, uint16_t id)  	return connection_register(path, &src, &dst, id);  } -static int panu_probe(struct btd_device *device, GSList *records) +static int panu_probe(struct btd_device_driver *driver, +			struct btd_device *device, GSList *records)  {  	return network_probe(device, BNEP_SVC_PANU);  } -static int gn_probe(struct btd_device *device, GSList *records) +static int gn_probe(struct btd_device_driver *driver, +			struct btd_device *device, GSList *records)  {  	return network_probe(device, BNEP_SVC_GN);  } -static int nap_probe(struct btd_device *device, GSList *records) +static int nap_probe(struct btd_device_driver *driver, +			struct btd_device *device, GSList *records)  {  	return network_probe(device, BNEP_SVC_NAP);  } @@ -122,17 +125,20 @@ static void network_remove(struct btd_device *device, uint16_t id)  	connection_unregister(path, id);  } -static void panu_remove(struct btd_device *device) +static void panu_remove(struct btd_device_driver *driver, +			struct btd_device *device)  {  	network_remove(device, BNEP_SVC_PANU);  } -static void gn_remove(struct btd_device *device) +static void gn_remove(struct btd_device_driver *driver, +			struct btd_device *device)  {  	network_remove(device, BNEP_SVC_GN);  } -static void nap_remove(struct btd_device *device) +static void nap_remove(struct btd_device_driver *driver, +			struct btd_device *device)  {  	network_remove(device, BNEP_SVC_NAP);  } diff --git a/serial/main.c b/serial/main.c index 7a8d01f3..1d7cf228 100644 --- a/serial/main.c +++ b/serial/main.c @@ -97,7 +97,8 @@ static GDBusMethodTable serial_methods[] = {  static DBusConnection *conn; -static int serial_probe(struct btd_device *device, GSList *records) +static int serial_probe(struct btd_device_driver *driver, +			struct btd_device *device, GSList *records)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); @@ -110,7 +111,8 @@ static int serial_probe(struct btd_device *device, GSList *records)  	return 0;  } -static void serial_remove(struct btd_device *device) +static void serial_remove(struct btd_device_driver *driver, +				struct btd_device *device)  {  	const gchar *path = device_get_path(device);  	DBG("path %s", path); | 
