From e1d92d253c5db96bdc8fe2a21e463fc730570311 Mon Sep 17 00:00:00 2001 From: Alok Barsode Date: Thu, 12 Jan 2012 15:13:41 +0200 Subject: [PATCH] technology: Register a technology is there's a driver for it Connman should not handle technologies whose drivers are not compiled in. This patch also avoids connman controlling the rfkill switches for technologies not compiled in. Fixes BMC#24549. --- src/technology.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/technology.c b/src/technology.c index 02ba6f3..c20ffa8 100644 --- a/src/technology.c +++ b/src/technology.c @@ -585,20 +585,36 @@ static struct connman_technology *technology_find(enum connman_service_type type static struct connman_technology *technology_get(enum connman_service_type type) { struct connman_technology *technology; + struct connman_technology_driver *driver = NULL; const char *str; GSList *list; + int err; DBG("type %d", type); + str = __connman_service_type2string(type); + if (str == NULL) + return NULL; + technology = technology_find(type); - if (technology != NULL) { - __sync_fetch_and_add(&technology->refcount, 1); - goto done; + if (technology != NULL) + return technology; + + /* First check if we have a driver for this technology type */ + for (list = driver_list; list; list = list->next) { + driver = list->data; + + if (driver->type == type) + break; + else + driver = NULL; } - str = __connman_service_type2string(type); - if (str == NULL) + if (driver == NULL) { + DBG("No matching driver found for %s.", + __connman_service_type2string(type)); return NULL; + } technology = g_try_new0(struct connman_technology, 1); if (technology == NULL) @@ -632,24 +648,11 @@ static struct connman_technology *technology_get(enum connman_service_type type) technology_added_signal(technology); - if (technology->driver != NULL) - goto done; - - for (list = driver_list; list; list = list->next) { - struct connman_technology_driver *driver = list->data; - - DBG("driver %p name %s", driver, driver->name); - - if (driver->type != technology->type) - continue; - - if (driver->probe(technology) == 0) { - technology->driver = driver; - break; - } - } + technology->driver = driver; + err = driver->probe(technology); + if (err != 0) + DBG("Driver probe failed for technology %p", technology); -done: DBG("technology %p", technology); return technology; -- 2.7.4