diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2022-06-30 00:58:15 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2022-06-30 11:15:04 +0200 |
commit | 7a3cbfec64808c6700f4354703a54a09e3e52c10 (patch) | |
tree | 64bf0cef815b1b38133c543879ac240272acda77 | |
parent | b91823012a870cbee59716c4de4578b33f47a6e6 (diff) |
port-qmi: monitor consecutive timeouts
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | src/mm-port-qmi.c | 42 |
3 files changed, 44 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index 490c70f2..2352f0b2 100644 --- a/configure.ac +++ b/configure.ac @@ -422,7 +422,7 @@ dnl----------------------------------------------------------------------------- dnl QMI support (enabled by default) dnl -LIBQMI_VERSION=1.31.7 +LIBQMI_VERSION=1.31.8 AC_ARG_WITH(qmi, AS_HELP_STRING([--without-qmi], [Build without QMI support]), [], [with_qmi=yes]) AM_CONDITIONAL(WITH_QMI, test "x$with_qmi" = "xyes") diff --git a/meson.build b/meson.build index 60c5dee1..5ceebe45 100644 --- a/meson.build +++ b/meson.build @@ -247,7 +247,7 @@ config_h.set('WITH_MBIM', enable_mbim) # QMI support (enabled by default) enable_qmi = get_option('qmi') if enable_qmi - qmi_glib_dep = dependency('qmi-glib', version: '>= 1.31.7') + qmi_glib_dep = dependency('qmi-glib', version: '>= 1.31.8') endif config_h.set('WITH_QMI', enable_qmi) diff --git a/src/mm-port-qmi.c b/src/mm-port-qmi.c index 9b7eae15..0fedd80d 100644 --- a/src/mm-port-qmi.c +++ b/src/mm-port-qmi.c @@ -64,6 +64,8 @@ struct _MMPortQmiPrivate { QrtrNode *node; #endif + /* timeout monitoring */ + gulong timeout_monitoring_id; /* endpoint info */ gulong endpoint_info_signal_id; QmiDataEndpointType endpoint_type; @@ -189,6 +191,41 @@ mm_port_qmi_get_endpoint_interface_number (MMPortQmi *self) /*****************************************************************************/ +static void +reset_timeout_monitoring (MMPortQmi *self, + QmiDevice *qmi_device) +{ + if (self->priv->timeout_monitoring_id && qmi_device) { + g_signal_handler_disconnect (qmi_device, self->priv->timeout_monitoring_id); + self->priv->timeout_monitoring_id = 0; + } +} + +static void +consecutive_timeouts_updated_cb (MMPortQmi *self, + GParamSpec *pspec, + QmiDevice *qmi_device) +{ + g_signal_emit_by_name (self, MM_PORT_SIGNAL_TIMED_OUT, qmi_device_get_consecutive_timeouts (qmi_device)); +} + +static void +setup_timeout_monitoring (MMPortQmi *self, + QmiDevice *qmi_device) +{ + g_assert (qmi_device); + + reset_timeout_monitoring (self, qmi_device); + + g_assert (!self->priv->timeout_monitoring_id); + self->priv->timeout_monitoring_id = g_signal_connect_swapped (qmi_device, + "notify::" QMI_DEVICE_CONSECUTIVE_TIMEOUTS, + G_CALLBACK (consecutive_timeouts_updated_cb), + self); +} + +/*****************************************************************************/ + void mm_port_qmi_release_client (MMPortQmi *self, QmiService service, @@ -2491,6 +2528,7 @@ port_open_step (GTask *task) g_assert (ctx->device); g_assert (!self->priv->qmi_device); self->priv->qmi_device = g_object_ref (ctx->device); + setup_timeout_monitoring (self, ctx->device); self->priv->in_progress = FALSE; g_task_return_boolean (task, TRUE); g_object_unref (task); @@ -2629,6 +2667,9 @@ mm_port_qmi_close (MMPortQmi *self, ctx->qmi_device = g_steal_pointer (&self->priv->qmi_device); g_task_set_task_data (task, ctx, (GDestroyNotify)port_qmi_close_context_free); + /* Reset timeout monitoring logic */ + reset_timeout_monitoring (self, ctx->qmi_device); + /* Release all allocated clients */ for (l = self->priv->services; l; l = g_list_next (l)) { ServiceInfo *info = l->data; @@ -2769,6 +2810,7 @@ dispose (GObject *object) g_clear_object (&self->priv->node); #endif /* Clear device object */ + reset_timeout_monitoring (self, self->priv->qmi_device); g_clear_object (&self->priv->qmi_device); g_clear_pointer (&self->priv->net_driver, g_free); |