diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-12-09 15:20:12 +0100 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2019-01-03 18:53:52 +0000 |
commit | 3c7437d791cf4e805d989ef940aa805f9ecc3848 (patch) | |
tree | b2a03c2dcd3112481e700be2fc2b3040665980db /src/mm-iface-modem-firmware.c | |
parent | 8e342cf1204379a11bfe55941d4e722575cb364f (diff) |
iface-modem-firmware: make the interface always available
We no longer "check for support" of this interface, it will always be
available for all modem objects.
The only implementation that used this interface was the QMI one, and
only for a very small subset of devices (those supporting the "QMI DMS
List Stored Images" operation). The logic was changed so that the list
of stored images wasn't preloaded during the support check; it will
now instead be preloaded during the first call to List().
Diffstat (limited to 'src/mm-iface-modem-firmware.c')
-rw-r--r-- | src/mm-iface-modem-firmware.c | 126 |
1 files changed, 18 insertions, 108 deletions
diff --git a/src/mm-iface-modem-firmware.c b/src/mm-iface-modem-firmware.c index bce5e294..06f07754 100644 --- a/src/mm-iface-modem-firmware.c +++ b/src/mm-iface-modem-firmware.c @@ -21,12 +21,6 @@ #include "mm-iface-modem-firmware.h" #include "mm-log.h" -#define SUPPORT_CHECKED_TAG "firmware-support-checked-tag" -#define SUPPORTED_TAG "firmware-supported-tag" - -static GQuark support_checked_quark; -static GQuark supported_quark; - /*****************************************************************************/ void @@ -249,15 +243,13 @@ static void interface_initialization_step (GTask *task); typedef enum { INITIALIZATION_STEP_FIRST, - INITIALIZATION_STEP_CHECK_SUPPORT, - INITIALIZATION_STEP_FAIL_IF_UNSUPPORTED, INITIALIZATION_STEP_UPDATE_SETTINGS, INITIALIZATION_STEP_LAST } InitializationStep; struct _InitializationContext { MmGdbusModemFirmware *skeleton; - InitializationStep step; + InitializationStep step; }; static void @@ -267,6 +259,14 @@ initialization_context_free (InitializationContext *ctx) g_free (ctx); } +gboolean +mm_iface_modem_firmware_initialize_finish (MMIfaceModemFirmware *self, + GAsyncResult *res, + GError **error) +{ + return g_task_propagate_boolean (G_TASK (res), error); +} + static void load_update_settings_ready (MMIfaceModemFirmware *self, GAsyncResult *res, @@ -299,35 +299,6 @@ load_update_settings_ready (MMIfaceModemFirmware *self, } static void -check_support_ready (MMIfaceModemFirmware *self, - GAsyncResult *res, - GTask *task) -{ - InitializationContext *ctx; - GError *error = NULL; - - if (!MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->check_support_finish (self, - res, - &error)) { - if (error) { - /* This error shouldn't be treated as critical */ - mm_dbg ("Firmware support check failed: '%s'", error->message); - g_error_free (error); - } - } else { - /* Firmware is supported! */ - g_object_set_qdata (G_OBJECT (self), - supported_quark, - GUINT_TO_POINTER (TRUE)); - } - - /* Go on to next step */ - ctx = g_task_get_task_data (task); - ctx->step++; - interface_initialization_step (task); -} - -static void interface_initialization_step (GTask *task) { MMIfaceModemFirmware *self; @@ -344,54 +315,6 @@ interface_initialization_step (GTask *task) switch (ctx->step) { case INITIALIZATION_STEP_FIRST: - /* Setup quarks if we didn't do it before */ - if (G_UNLIKELY (!support_checked_quark)) - support_checked_quark = (g_quark_from_static_string ( - SUPPORT_CHECKED_TAG)); - if (G_UNLIKELY (!supported_quark)) - supported_quark = (g_quark_from_static_string ( - SUPPORTED_TAG)); - - /* Fall down to next step */ - ctx->step++; - - case INITIALIZATION_STEP_CHECK_SUPPORT: - if (!GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (self), - support_checked_quark))) { - /* Set the checked flag so that we don't run it again */ - g_object_set_qdata (G_OBJECT (self), - support_checked_quark, - GUINT_TO_POINTER (TRUE)); - /* Initially, assume we don't support it */ - g_object_set_qdata (G_OBJECT (self), - supported_quark, - GUINT_TO_POINTER (FALSE)); - - if (MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->check_support && - MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->check_support_finish) { - MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->check_support ( - self, - (GAsyncReadyCallback)check_support_ready, - task); - return; - } - - /* If there is no implementation to check support, assume we DON'T - * support it. */ - } - /* Fall down to next step */ - ctx->step++; - - case INITIALIZATION_STEP_FAIL_IF_UNSUPPORTED: - if (!GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (self), - supported_quark))) { - g_task_return_new_error (task, - MM_CORE_ERROR, - MM_CORE_ERROR_UNSUPPORTED, - "Firmware interface not available"); - g_object_unref (task); - return; - } /* Fall down to next step */ ctx->step++; @@ -411,14 +334,10 @@ interface_initialization_step (GTask *task) /* We are done without errors! */ /* Handle method invocations */ - g_signal_connect (ctx->skeleton, - "handle-list", - G_CALLBACK (handle_list), - self); - g_signal_connect (ctx->skeleton, - "handle-select", - G_CALLBACK (handle_select), - self); + g_object_connect (ctx->skeleton, + "signal::handle-list", G_CALLBACK (handle_list), self, + "signal::handle-select", G_CALLBACK (handle_select), self, + NULL); /* Finally, export the new interface */ mm_gdbus_object_skeleton_set_modem_firmware (MM_GDBUS_OBJECT_SKELETON (self), @@ -432,23 +351,15 @@ interface_initialization_step (GTask *task) g_assert_not_reached (); } -gboolean -mm_iface_modem_firmware_initialize_finish (MMIfaceModemFirmware *self, - GAsyncResult *res, - GError **error) -{ - return g_task_propagate_boolean (G_TASK (res), error); -} - void mm_iface_modem_firmware_initialize (MMIfaceModemFirmware *self, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { InitializationContext *ctx; - MmGdbusModemFirmware *skeleton = NULL; - GTask *task; + MmGdbusModemFirmware *skeleton = NULL; + GTask *task; /* Did we already create it? */ g_object_get (self, @@ -462,7 +373,6 @@ mm_iface_modem_firmware_initialize (MMIfaceModemFirmware *self, } /* Perform async initialization here */ - ctx = g_new0 (InitializationContext, 1); ctx->step = INITIALIZATION_STEP_FIRST; ctx->skeleton = skeleton; |