aboutsummaryrefslogtreecommitdiff
path: root/plugins/ublox/mm-plugin-ublox.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-05-08 09:49:11 +0200
committerAleksander Morgado <aleksander@aleksander.es>2018-05-08 09:51:19 +0200
commit3e469e7b8055a0a11abc8304ec44c3df39e74d3d (patch)
tree032973d5bb7ea696f53e267c047c422edc669b8b /plugins/ublox/mm-plugin-ublox.c
parent1a56b97061252fa4605bd0b58de491bbe43a6685 (diff)
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.
Diffstat (limited to 'plugins/ublox/mm-plugin-ublox.c')
-rw-r--r--plugins/ublox/mm-plugin-ublox.c25
1 files changed, 12 insertions, 13 deletions
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);
}
/*****************************************************************************/