@@ -1101,17 +1101,19 @@ struct discover_data {
void *user_data;
qmi_destroy_func_t destroy;
uint16_t tid;
- guint timeout;
+ struct l_timeout *timeout;
+ struct l_idle *idle;
};
-static void discover_data_free(gpointer user_data)
+static void discover_data_free(void *user_data)
{
struct discover_data *data = user_data;
- if (data->timeout) {
- g_source_remove(data->timeout);
- data->timeout = 0;
- }
+ if (data->timeout)
+ l_timeout_remove(data->timeout);
+
+ if (data->idle)
+ l_idle_remove(data->idle);
if (data->destroy)
data->destroy(data->user_data);
@@ -1253,17 +1255,33 @@ static struct qmi_request *find_control_request(struct qmi_device *device,
return req;
}
-static gboolean discover_reply(gpointer user_data)
+
+static void discover_reply_idle(struct l_idle *idle, void *user_data)
+{
+ struct discover_data *data = user_data;
+ struct qmi_device *device = data->device;
+
+ l_idle_remove(data->idle);
+ data->idle = NULL;
+
+ if (data->func)
+ data->func(data->user_data);
+
+ __qmi_device_discovery_complete(device, &data->super);
+}
+
+static void discover_reply_timeout(struct l_timeout *timeout, void *user_data)
{
struct discover_data *data = user_data;
struct qmi_device *device = data->device;
struct qmi_request *req;
+ l_timeout_remove(data->timeout);
+ data->timeout = NULL;
+
/* remove request from queues */
req = find_control_request(device, data->tid);
- data->timeout = 0;
-
if (data->func)
data->func(data->user_data);
@@ -1271,8 +1289,6 @@ static gboolean discover_reply(gpointer user_data)
if (req)
__request_free(req);
-
- return FALSE;
}
bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
@@ -1295,7 +1311,7 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
data->destroy = destroy;
if (device->version_list) {
- data->timeout = g_timeout_add_seconds(0, discover_reply, data);
+ data->idle = l_idle_create(discover_reply_idle, data, NULL);
__qmi_device_discovery_started(device, &data->super);
return true;
}
@@ -1305,7 +1321,7 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
NULL, 0, discover_callback, data);
data->tid = __request_submit(device, req);
- data->timeout = g_timeout_add_seconds(5, discover_reply, data);
+ data->timeout = l_timeout_create(5, discover_reply_timeout, data, NULL);
__qmi_device_discovery_started(device, &data->super);