From: Alok Barsode <alok.bars...@nokia.com>

EnableTechnology used to traverse the whole element tree enabling devices.
Instead traverse technology->device_list and enable each device.
---
 src/connman.h    |    3 ++-
 src/element.c    |   53 -----------------------------------------------------
 src/manager.c    |    2 +-
 src/technology.c |   26 ++++++++++++++++++++++++++
 4 files changed, 29 insertions(+), 55 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index f6521eb..5d3d74e 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -180,7 +180,6 @@ struct connman_device *__connman_element_get_device(struct 
connman_element *elem
 
 struct connman_device *__connman_element_find_device(enum connman_service_type 
type);
 int __connman_element_request_scan(enum connman_service_type type);
-int __connman_element_enable_technology(enum connman_service_type type);
 int __connman_element_disable_technology(enum connman_service_type type);
 
 gboolean __connman_element_device_isfiltered(const char *devname);
@@ -316,6 +315,8 @@ void __connman_technology_list(DBusMessageIter *iter, void 
*user_data);
 int __connman_technology_add_device(struct connman_device *device);
 int __connman_technology_remove_device(struct connman_device *device);
 int __connman_technology_enable(enum connman_service_type type);
+int technology_enable(enum connman_service_type type);
+
 int __connman_technology_disable(enum connman_service_type type);
 int __connman_technology_add_rfkill(unsigned int index,
                                        enum connman_service_type type,
diff --git a/src/element.c b/src/element.c
index ac62aaa..2584fbc 100644
--- a/src/element.c
+++ b/src/element.c
@@ -317,59 +317,6 @@ int __connman_element_request_scan(enum 
connman_service_type type)
        return 0;
 }
 
-static gboolean enable_technology(GNode *node, gpointer user_data)
-{
-       struct connman_element *element = node->data;
-       struct find_data *data = user_data;
-       enum connman_service_type type;
-       int err;
-
-       if (element->type != CONNMAN_ELEMENT_TYPE_DEVICE)
-               return FALSE;
-
-       if (element->device == NULL)
-               return FALSE;
-
-       type = __connman_device_get_service_type(element->device);
-
-       switch (type) {
-       case CONNMAN_SERVICE_TYPE_UNKNOWN:
-       case CONNMAN_SERVICE_TYPE_SYSTEM:
-       case CONNMAN_SERVICE_TYPE_GPS:
-       case CONNMAN_SERVICE_TYPE_VPN:
-       case CONNMAN_SERVICE_TYPE_GADGET:
-               return FALSE;
-       case CONNMAN_SERVICE_TYPE_ETHERNET:
-       case CONNMAN_SERVICE_TYPE_WIFI:
-       case CONNMAN_SERVICE_TYPE_WIMAX:
-       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
-       case CONNMAN_SERVICE_TYPE_CELLULAR:
-               if (data->type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
-                                                       data->type != type)
-                       return FALSE;
-               break;
-       }
-
-       err = __connman_device_enable(element->device);
-       if (err == 0 || (err < 0 && err == -EINPROGRESS))
-               data->error = FALSE;
-
-       return FALSE;
-}
-
-int __connman_element_enable_technology(enum connman_service_type type)
-{
-       struct find_data data = { .type = type, .device = NULL, .error = TRUE };
-
-       g_node_traverse(element_root, G_PRE_ORDER,
-                               G_TRAVERSE_ALL, -1, enable_technology, &data);
-
-       if (data.error == TRUE)
-               return -ENODEV;
-
-       return 0;
-}
-
 static gboolean disable_technology(GNode *node, gpointer user_data)
 {
        struct connman_element *element = node->data;
diff --git a/src/manager.c b/src/manager.c
index 0a11f5d..2c7d632 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -329,7 +329,7 @@ static DBusMessage *enable_technology(DBusConnection *conn,
        technology_enabled = TRUE;
        technology_pending = dbus_message_ref(msg);
 
-       err = __connman_element_enable_technology(type);
+       err = technology_enable(type);
        if (err < 0 && err != -EINPROGRESS)
                technology_reply(-err);
        else
diff --git a/src/technology.c b/src/technology.c
index 513fffc..077a35c 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -674,6 +674,32 @@ int __connman_technology_remove_device(struct 
connman_device *device)
        return 0;
 }
 
+int technology_enable(enum connman_service_type type)
+{
+       GSList *list;
+       struct connman_technology *technology;
+
+       technology = technology_find(type);
+       if (technology == NULL)
+               return -ENXIO;
+
+       if (technology->device_list == NULL)
+               return -ENODEV;
+
+       for (list = technology->device_list; list; list = list->next) {
+               struct connman_device *device = list->data;
+
+               /* Tracking error from every device is not possible.
+               hence ignore the return value */
+               __connman_device_enable(device);
+       }
+
+       /* This will trigger a 15 sec timeout. This gives enough time for
+       the drivers to bring up the devices. If they fail technology_abort
+       will be invoked. */
+       return -EINPROGRESS;
+}
+
 int __connman_technology_enable(enum connman_service_type type)
 {
        struct connman_technology *technology;
-- 
1.7.0.4

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to