From: Alok Barsode <[email protected]>

Replace __connman_device_request_scan with __connman_technology_request_scan.
__connman_device_request_scan iterated over all the devices.
__connman_technology_request_scan iterates over the ones which belong to the
requested technology.
---
 src/connman.h    |    3 ++-
 src/device.c     |   49 +------------------------------------------------
 src/technology.c |   35 ++++++++++++++++++++++++++++++++++-
 3 files changed, 37 insertions(+), 50 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 8609614..0b6b898 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -412,6 +412,7 @@ void __connman_technology_add_interface(enum 
connman_service_type type,
                                int index, const char *name, const char *ident);
 void __connman_technology_remove_interface(enum connman_service_type type,
                                int index, const char *name, const char *ident);
+int __connman_technology_request_scan(enum connman_service_type type);
 
 #include <connman/device.h>
 
@@ -422,7 +423,7 @@ void __connman_device_list(DBusMessageIter *iter, void 
*user_data);
 
 enum connman_service_type __connman_device_get_service_type(struct 
connman_device *device);
 struct connman_device *__connman_device_find_device(enum connman_service_type 
type);
-int __connman_device_request_scan(enum connman_service_type type);
+int __connman_device_request_scan(struct connman_device *device);
 int __connman_device_request_hidden_scan(struct connman_device *device,
                                const char *ssid, unsigned int ssid_len,
                                const char *identity, const char *passphrase);
diff --git a/src/device.c b/src/device.c
index e7568f6..451b7ef 100644
--- a/src/device.c
+++ b/src/device.c
@@ -714,7 +714,7 @@ int connman_device_set_powered(struct connman_device 
*device,
        return 0;
 }
 
-static int device_scan(struct connman_device *device)
+int __connman_device_request_scan(struct connman_device *device)
 {
        if (!device->driver || !device->driver->scan)
                return -EOPNOTSUPP;
@@ -1161,53 +1161,6 @@ struct connman_device *__connman_device_find_device(
        return NULL;
 }
 
-int __connman_device_request_scan(enum connman_service_type type)
-{
-       connman_bool_t success = FALSE;
-       int last_err = -ENOSYS;
-       GSList *list;
-       int err;
-
-       switch (type) {
-       case CONNMAN_SERVICE_TYPE_UNKNOWN:
-       case CONNMAN_SERVICE_TYPE_SYSTEM:
-       case CONNMAN_SERVICE_TYPE_ETHERNET:
-       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
-       case CONNMAN_SERVICE_TYPE_CELLULAR:
-       case CONNMAN_SERVICE_TYPE_GPS:
-       case CONNMAN_SERVICE_TYPE_VPN:
-       case CONNMAN_SERVICE_TYPE_GADGET:
-               return -EOPNOTSUPP;
-       case CONNMAN_SERVICE_TYPE_WIFI:
-       case CONNMAN_SERVICE_TYPE_WIMAX:
-               break;
-       }
-
-       for (list = device_list; list != NULL; list = list->next) {
-               struct connman_device *device = list->data;
-               enum connman_service_type service_type =
-                       __connman_device_get_service_type(device);
-
-               if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
-                               service_type != type) {
-                       continue;
-               }
-
-               err = device_scan(device);
-               if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
-                       success = TRUE;
-               } else {
-                       last_err = err;
-                       DBG("device %p err %d", device, err);
-               }
-       }
-
-       if (success == TRUE)
-               return 0;
-
-       return last_err;
-}
-
 int __connman_device_request_hidden_scan(struct connman_device *device,
                                const char *ssid, unsigned int ssid_len,
                                const char *identity, const char *passphrase)
diff --git a/src/technology.c b/src/technology.c
index 2b34f50..ea984c5 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -769,6 +769,39 @@ static struct connman_technology *technology_find(enum 
connman_service_type type
        return NULL;
 }
 
+int __connman_technology_request_scan(enum connman_service_type type)
+{
+       struct connman_technology *technology;
+       GSList *list;
+       connman_bool_t success = FALSE;
+       int last_err = -ENOSYS;
+       int err;
+
+       technology = technology_find(type);
+
+       if (technology == NULL)
+               return -ENXIO;
+
+       for (list = technology->device_list; list != NULL; list = list->next) {
+               struct connman_device *device = list->data;
+
+               err = __connman_device_request_scan(device);
+               if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
+                       success = TRUE;
+               } else if (err == -EOPNOTSUPP) {
+                       return err;
+               } else {
+                       last_err = err;
+                       DBG("device %p err %d", device, err);
+               }
+       }
+
+       if (success == TRUE)
+               return 0;
+
+       return last_err;
+}
+
 static void reply_scan_pending(struct connman_technology *technology, int err)
 {
        DBusMessage *reply;
@@ -842,7 +875,7 @@ static DBusMessage *scan(DBusConnection *conn, DBusMessage 
*msg, void *data)
        technology->scan_pending =
                g_slist_prepend(technology->scan_pending, msg);
 
-       err = __connman_device_request_scan(technology->type);
+       err = __connman_technology_request_scan(technology->type);
        if (err < 0)
                reply_scan_pending(technology, err);
 
-- 
1.7.5.4

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to