From 3e469e7b8055a0a11abc8304ec44c3df39e74d3d Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 8 May 2018 09:49:11 +0200 Subject: u-blox: don't run quick AT procedure if READY_DELAY not configured The quick AT probe procedure is only meaningful to avoid waiting the +READY URC delay. If there is no such delay configured, we shouldn't run the quick AT probe (as a failure in the AT probe may also trigger a +READY URC delay). Just read the udev tag value early and complete the task if the delay is not configured. --- plugins/ublox/mm-plugin-ublox.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'plugins/ublox/mm-plugin-ublox.c') diff --git a/plugins/ublox/mm-plugin-ublox.c b/plugins/ublox/mm-plugin-ublox.c index 4f16346a..6a0d140b 100644 --- a/plugins/ublox/mm-plugin-ublox.c +++ b/plugins/ublox/mm-plugin-ublox.c @@ -202,19 +202,25 @@ ublox_custom_init (MMPortProbe *probe, { GTask *task; CustomInitContext *ctx; + gint wait_timeout_secs; task = g_task_new (probe, cancellable, callback, user_data); + /* If no explicit READY_DELAY configured, we don't need a custom init procedure */ + wait_timeout_secs = mm_kernel_device_get_property_as_int (mm_port_probe_peek_port (probe), "ID_MM_UBLOX_PORT_READY_DELAY"); + if (wait_timeout_secs <= 0) { + g_task_return_boolean (task, TRUE); + g_object_unref (task); + return; + } + ctx = g_slice_new0 (CustomInitContext); + ctx->wait_timeout_secs = wait_timeout_secs; ctx->port = g_object_ref (port); ctx->ready_regex = g_regex_new ("\\r\\n\\+AT:\\s*READY\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); g_task_set_task_data (task, ctx, (GDestroyNotify) custom_init_context_free); - ctx->wait_timeout_secs = mm_kernel_device_get_property_as_int (mm_port_probe_peek_port(probe), "ID_MM_UBLOX_PORT_READY_DELAY"); - if (ctx->wait_timeout_secs < 0) - ctx->wait_timeout_secs = 0; - /* If the device hasn't been plugged in right away, we assume it was already * running for some time. We validate the assumption with a quick AT probe, * and if it times out, we run the explicit READY wait from scratch (e.g. @@ -232,15 +238,8 @@ ublox_custom_init (MMPortProbe *probe, return; } - if (ctx->wait_timeout_secs > 0) { - /* Device hotplugged and has a defined ready delay, wait for READY URC */ - wait_for_ready (task); - return; - } - - /* Otherwise, no need for any custom wait */ - g_task_return_boolean (task, TRUE); - g_object_unref (task); + /* Device hotplugged and has a defined ready delay, wait for READY URC */ + wait_for_ready (task); } /*****************************************************************************/ -- cgit v1.2.3-70-g09d2