summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-06-08 20:38:09 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-06-08 20:38:09 +0000
commit6061f1a889c90d4d408ca12b63b2db6235c73bae (patch)
treecdce17f5c8f056c3581a14801652fa718fcf8134 /hcid
parent19363c93557f8163f6f0a7ef0fe17c1eb73c5c96 (diff)
Keep track of attached drivers
Diffstat (limited to 'hcid')
-rw-r--r--hcid/device.c27
-rw-r--r--hcid/device.h1
2 files changed, 21 insertions, 7 deletions
diff --git a/hcid/device.c b/hcid/device.c
index fee2a4e8..7213cbf2 100644
--- a/hcid/device.c
+++ b/hcid/device.c
@@ -1090,10 +1090,18 @@ struct device *device_create(DBusConnection *conn, struct adapter *adapter,
void device_remove(DBusConnection *conn, struct device *device)
{
+ GSList *list;
+ struct btd_device_driver *driver;
gchar *path = g_strdup(device->path);
debug("Removing device %s", path);
+ for (list = device->drivers; list; list = list->next) {
+ driver = (struct btd_device_driver *) list->data;
+
+ driver->remove(device->path);
+ }
+
g_dbus_unregister_interface(conn, path, DEVICE_INTERFACE);
g_free(path);
@@ -1106,31 +1114,36 @@ gint device_address_cmp(struct device *device, const gchar *address)
static void probe_matching_drivers(struct device *device)
{
- GSList *drv_list;
- const char **drv_uuid;
+ GSList *list;
+ const char **uuid;
struct btd_device_driver *driver;
int err;
debug("Probe drivers for %s", device->path);
- for (drv_list = drivers; drv_list; drv_list = drv_list->next) {
- driver = (struct btd_device_driver *) drv_list->data;
+ for (list = drivers; list; list = list->next) {
+ driver = (struct btd_device_driver *) list->data;
gboolean do_probe = FALSE;
- for (drv_uuid = driver->uuids; *drv_uuid; drv_uuid++) {
+ for (uuid = driver->uuids; *uuid; uuid++) {
GSList *match = g_slist_find_custom(device->uuids,
- *drv_uuid, (GCompareFunc) strcasecmp);
+ *uuid, (GCompareFunc) strcasecmp);
if (match) {
do_probe = TRUE;
break;
}
}
- if (do_probe == TRUE) {
+ if (do_probe == TRUE && !g_slist_find_custom(device->drivers,
+ driver->name, (GCompareFunc) strcmp)) {
+
err = driver->probe(device->path);
if (err < 0)
error("probe failed for driver %s",
driver->name);
+ else
+ device->drivers = g_slist_append(device->drivers,
+ driver);
}
}
}
diff --git a/hcid/device.h b/hcid/device.h
index ff687231..2dd7e6c7 100644
--- a/hcid/device.h
+++ b/hcid/device.h
@@ -29,6 +29,7 @@ struct device {
gchar *path;
struct adapter *adapter;
GSList *uuids;
+ GSList *drivers;
gboolean temporary;
struct agent *agent;
};