technology: Optimize __connman_technology_remove_interface()
authorAlok Barsode <alok.barsode@nokia.com>
Mon, 7 Feb 2011 12:43:06 +0000 (14:43 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 8 Feb 2011 14:44:11 +0000 (15:44 +0100)
Using technology_find() instead of looping through technology_list.

src/technology.c

index 0a89b1a..a5366dc 100644 (file)
@@ -580,7 +580,7 @@ void __connman_technology_add_interface(enum connman_service_type type,
 void __connman_technology_remove_interface(enum connman_service_type type,
                                int index, const char *name, const char *ident)
 {
-       GSList *list;
+       struct connman_technology *technology;
 
        switch (type) {
        case CONNMAN_SERVICE_TYPE_UNKNOWN:
@@ -600,20 +600,15 @@ void __connman_technology_remove_interface(enum connman_service_type type,
        connman_info("Remove interface %s [ %s ]", name,
                                __connman_service_type2string(type));
 
-       for (list = technology_list; list; list = list->next) {
-               struct connman_technology *technology = list->data;
-
-               if (technology->type != type)
-                       continue;
+       technology = technology_find(type);
 
-               if (technology->driver == NULL)
-                       continue;
+       if (technology == NULL || technology->driver == NULL)
+               return;
 
-               if (technology->driver->remove_interface)
-                       technology->driver->remove_interface(technology, index);
+       if (technology->driver->remove_interface)
+               technology->driver->remove_interface(technology, index);
 
-               technology_put(technology);
-       }
+       technology_put(technology);
 }
 
 static void unregister_technology(gpointer data)