diff options
-rw-r--r-- | plugins/foxconn/mm-broadband-modem-mbim-foxconn.c | 83 |
1 files changed, 35 insertions, 48 deletions
diff --git a/plugins/foxconn/mm-broadband-modem-mbim-foxconn.c b/plugins/foxconn/mm-broadband-modem-mbim-foxconn.c index 7878dbdd..c57c330c 100644 --- a/plugins/foxconn/mm-broadband-modem-mbim-foxconn.c +++ b/plugins/foxconn/mm-broadband-modem-mbim-foxconn.c @@ -86,17 +86,20 @@ foxconn_get_firmware_version_over_dms_service_ready (QmiClientDms *client, GAsyncResult *res, GTask *task) { - QmiMessageDmsFoxconnGetFirmwareVersionOutput *output; - GError *error = NULL; - MMFirmwareUpdateSettings *update_settings = NULL; - const gchar *str; - MMIfaceModemFirmware *self; - guint vendor_id; - guint product_id; + g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionOutput) output = NULL; + GError *error = NULL; + MMFirmwareUpdateSettings *update_settings = NULL; + const gchar *str; + MMIfaceModemFirmware *self; + guint vendor_id; + guint product_id; output = qmi_client_dms_foxconn_get_firmware_version_finish (client, res, &error); - if (!output || !qmi_message_dms_foxconn_get_firmware_version_output_get_result (output, &error)) - goto out; + if (!output || !qmi_message_dms_foxconn_get_firmware_version_output_get_result (output, &error)) { + g_task_return_error (task, error); + g_object_unref (task); + return; + } /* Create update settings now: * 0x105b is the T99W175 module, T99W175 supports QDU, @@ -113,20 +116,11 @@ foxconn_get_firmware_version_over_dms_service_ready (QmiClientDms *client, MM_MODEM_FIRMWARE_UPDATE_METHOD_QMI_PDC); mm_firmware_update_settings_set_fastboot_at (update_settings, "AT^FASTBOOT"); } - qmi_message_dms_foxconn_get_firmware_version_output_get_version (output, &str, NULL); mm_firmware_update_settings_set_version (update_settings, str); - out: - if (error) - g_task_return_error (task, error); - else { - g_assert (update_settings); - g_task_return_pointer (task, update_settings, g_object_unref); - } + g_task_return_pointer (task, update_settings, g_object_unref); g_object_unref (task); - if (output) - qmi_message_dms_foxconn_get_firmware_version_output_unref (output); } static void @@ -134,17 +128,20 @@ foxconn_get_firmware_version_over_fox_service_ready (QmiClientFox *client, GAsyncResult *res, GTask *task) { - QmiMessageFoxGetFirmwareVersionOutput *output; - GError *error = NULL; - MMFirmwareUpdateSettings *update_settings = NULL; - const gchar *str; - MMIfaceModemFirmware *self; - guint vendor_id; - guint product_id; + g_autoptr(QmiMessageFoxGetFirmwareVersionOutput) output = NULL; + GError *error = NULL; + MMFirmwareUpdateSettings *update_settings = NULL; + const gchar *str; + MMIfaceModemFirmware *self; + guint vendor_id; + guint product_id; output = qmi_client_fox_get_firmware_version_finish (client, res, &error); - if (!output || !qmi_message_fox_get_firmware_version_output_get_result (output, &error)) - goto out; + if (!output || !qmi_message_fox_get_firmware_version_output_get_result (output, &error)) { + g_task_return_error (task, error); + g_object_unref (task); + return; + } /* Create update settings now: * 0x105b is the T99W175 module, T99W175 supports QDU, @@ -165,26 +162,18 @@ foxconn_get_firmware_version_over_fox_service_ready (QmiClientFox *client, qmi_message_fox_get_firmware_version_output_get_version (output, &str, NULL); mm_firmware_update_settings_set_version (update_settings, str); - out: - if (error) - g_task_return_error (task, error); - else { - g_assert (update_settings); - g_task_return_pointer (task, update_settings, g_object_unref); - } + g_task_return_pointer (task, update_settings, g_object_unref); g_object_unref (task); - if (output) - qmi_message_fox_get_firmware_version_output_unref (output); } static void firmware_load_update_settings_over_dms_service (MMIfaceModemFirmware *self, GTask *task) { - QmiMessageDmsFoxconnGetFirmwareVersionInput *input = NULL; - QmiClient *client = NULL; - guint vendor_id; - guint product_id; + g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionInput) input = NULL; + QmiClient *client = NULL; + guint vendor_id; + guint product_id; client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_DMS, @@ -218,7 +207,6 @@ firmware_load_update_settings_over_dms_service (MMIfaceModemFirmware *self, NULL, (GAsyncReadyCallback)foxconn_get_firmware_version_over_dms_service_ready, task); - qmi_message_dms_foxconn_get_firmware_version_input_unref (input); } static void @@ -226,11 +214,11 @@ firmware_load_update_settings (MMIfaceModemFirmware *self, GAsyncReadyCallback callback, gpointer user_data) { - GTask *task; - QmiMessageFoxGetFirmwareVersionInput *input = NULL; - QmiClient *client = NULL; - guint vendor_id; - guint product_id; + GTask *task; + g_autoptr(QmiMessageFoxGetFirmwareVersionInput) input = NULL; + QmiClient *client = NULL; + guint vendor_id; + guint product_id; task = g_task_new (self, NULL, callback, user_data); @@ -265,7 +253,6 @@ firmware_load_update_settings (MMIfaceModemFirmware *self, NULL, (GAsyncReadyCallback)foxconn_get_firmware_version_over_fox_service_ready, task); - qmi_message_fox_get_firmware_version_input_unref (input); } #endif |