summaryrefslogtreecommitdiff
path: root/src/technology.c
diff options
context:
space:
mode:
authorAlok Barsode <alok.barsode@linux.intel.com>2012-01-12 15:13:41 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-01-16 12:16:38 +0100
commite1d92d253c5db96bdc8fe2a21e463fc730570311 (patch)
treeadc189afdbcad10b0d76687a3ef23f90a13df22d /src/technology.c
parent4545a49c59d7a7fe8fb9be3d9da2817ec62dbd27 (diff)
downloadconnman-e1d92d253c5db96bdc8fe2a21e463fc730570311.tar.gz
connman-e1d92d253c5db96bdc8fe2a21e463fc730570311.tar.bz2
connman-e1d92d253c5db96bdc8fe2a21e463fc730570311.zip
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.
Diffstat (limited to 'src/technology.c')
-rw-r--r--src/technology.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/technology.c b/src/technology.c
index 02ba6f31..c20ffa8a 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;