From 377d8e81b904afc1a4378bb89f5932b64a432d6e Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Wed, 8 Dec 2010 19:39:58 +0100 Subject: [PATCH] technology: Set technology driver to NULL when unregistering --- src/technology.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/technology.c b/src/technology.c index 8a0ce52..c5600e2 100644 --- a/src/technology.c +++ b/src/technology.c @@ -83,11 +83,24 @@ static gint compare_priority(gconstpointer a, gconstpointer b) */ int connman_technology_driver_register(struct connman_technology_driver *driver) { + GSList *list; + struct connman_technology *technology; + DBG("driver %p name %s", driver, driver->name); driver_list = g_slist_insert_sorted(driver_list, driver, compare_priority); + for (list = technology_list; list; list = list->next) { + technology = list->data; + + if (technology->driver != NULL) + continue; + + if (technology->type == driver->type) + technology->driver = driver; + } + return 0; } @@ -99,8 +112,23 @@ int connman_technology_driver_register(struct connman_technology_driver *driver) */ void connman_technology_driver_unregister(struct connman_technology_driver *driver) { + GSList *list; + struct connman_technology *technology; + DBG("driver %p name %s", driver, driver->name); + for (list = technology_list; list; list = list->next) { + technology = list->data; + + if (technology->driver == NULL) + continue; + + if (technology->type == driver->type) { + technology->driver->remove(technology); + technology->driver = NULL; + } + } + driver_list = g_slist_remove(driver_list, driver); } -- 2.7.4