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 /src | |
parent | b91823012a870cbee59716c4de4578b33f47a6e6 (diff) |
port-qmi: monitor consecutive timeouts
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-port-qmi.c | 42 |
1 files changed, 42 insertions, 0 deletions
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); |