foxconn: switch to use autoptr() in firmware info loading

This commit is contained in:
Aleksander Morgado
2022-03-25 14:01:50 +01:00
parent b81680a3fd
commit 4efb5f61cf

View File

@@ -86,17 +86,20 @@ foxconn_get_firmware_version_over_dms_service_ready (QmiClientDms *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
QmiMessageDmsFoxconnGetFirmwareVersionOutput *output; g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionOutput) output = NULL;
GError *error = NULL; GError *error = NULL;
MMFirmwareUpdateSettings *update_settings = NULL; MMFirmwareUpdateSettings *update_settings = NULL;
const gchar *str; const gchar *str;
MMIfaceModemFirmware *self; MMIfaceModemFirmware *self;
guint vendor_id; guint vendor_id;
guint product_id; guint product_id;
output = qmi_client_dms_foxconn_get_firmware_version_finish (client, res, &error); 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)) if (!output || !qmi_message_dms_foxconn_get_firmware_version_output_get_result (output, &error)) {
goto out; g_task_return_error (task, error);
g_object_unref (task);
return;
}
/* Create update settings now: /* Create update settings now:
* 0x105b is the T99W175 module, T99W175 supports QDU, * 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_MODEM_FIRMWARE_UPDATE_METHOD_QMI_PDC);
mm_firmware_update_settings_set_fastboot_at (update_settings, "AT^FASTBOOT"); mm_firmware_update_settings_set_fastboot_at (update_settings, "AT^FASTBOOT");
} }
qmi_message_dms_foxconn_get_firmware_version_output_get_version (output, &str, NULL); qmi_message_dms_foxconn_get_firmware_version_output_get_version (output, &str, NULL);
mm_firmware_update_settings_set_version (update_settings, str); mm_firmware_update_settings_set_version (update_settings, str);
out: g_task_return_pointer (task, update_settings, g_object_unref);
if (error)
g_task_return_error (task, error);
else {
g_assert (update_settings);
g_task_return_pointer (task, update_settings, g_object_unref);
}
g_object_unref (task); g_object_unref (task);
if (output)
qmi_message_dms_foxconn_get_firmware_version_output_unref (output);
} }
static void static void
@@ -134,17 +128,20 @@ foxconn_get_firmware_version_over_fox_service_ready (QmiClientFox *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
QmiMessageFoxGetFirmwareVersionOutput *output; g_autoptr(QmiMessageFoxGetFirmwareVersionOutput) output = NULL;
GError *error = NULL; GError *error = NULL;
MMFirmwareUpdateSettings *update_settings = NULL; MMFirmwareUpdateSettings *update_settings = NULL;
const gchar *str; const gchar *str;
MMIfaceModemFirmware *self; MMIfaceModemFirmware *self;
guint vendor_id; guint vendor_id;
guint product_id; guint product_id;
output = qmi_client_fox_get_firmware_version_finish (client, res, &error); output = qmi_client_fox_get_firmware_version_finish (client, res, &error);
if (!output || !qmi_message_fox_get_firmware_version_output_get_result (output, &error)) if (!output || !qmi_message_fox_get_firmware_version_output_get_result (output, &error)) {
goto out; g_task_return_error (task, error);
g_object_unref (task);
return;
}
/* Create update settings now: /* Create update settings now:
* 0x105b is the T99W175 module, T99W175 supports QDU, * 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); qmi_message_fox_get_firmware_version_output_get_version (output, &str, NULL);
mm_firmware_update_settings_set_version (update_settings, str); mm_firmware_update_settings_set_version (update_settings, str);
out: g_task_return_pointer (task, update_settings, g_object_unref);
if (error)
g_task_return_error (task, error);
else {
g_assert (update_settings);
g_task_return_pointer (task, update_settings, g_object_unref);
}
g_object_unref (task); g_object_unref (task);
if (output)
qmi_message_fox_get_firmware_version_output_unref (output);
} }
static void static void
firmware_load_update_settings_over_dms_service (MMIfaceModemFirmware *self, firmware_load_update_settings_over_dms_service (MMIfaceModemFirmware *self,
GTask *task) GTask *task)
{ {
QmiMessageDmsFoxconnGetFirmwareVersionInput *input = NULL; g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionInput) input = NULL;
QmiClient *client = NULL; QmiClient *client = NULL;
guint vendor_id; guint vendor_id;
guint product_id; guint product_id;
client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self), client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self),
QMI_SERVICE_DMS, QMI_SERVICE_DMS,
@@ -218,7 +207,6 @@ firmware_load_update_settings_over_dms_service (MMIfaceModemFirmware *self,
NULL, NULL,
(GAsyncReadyCallback)foxconn_get_firmware_version_over_dms_service_ready, (GAsyncReadyCallback)foxconn_get_firmware_version_over_dms_service_ready,
task); task);
qmi_message_dms_foxconn_get_firmware_version_input_unref (input);
} }
static void static void
@@ -226,11 +214,11 @@ firmware_load_update_settings (MMIfaceModemFirmware *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GTask *task; GTask *task;
QmiMessageFoxGetFirmwareVersionInput *input = NULL; g_autoptr(QmiMessageFoxGetFirmwareVersionInput) input = NULL;
QmiClient *client = NULL; QmiClient *client = NULL;
guint vendor_id; guint vendor_id;
guint product_id; guint product_id;
task = g_task_new (self, NULL, callback, user_data); task = g_task_new (self, NULL, callback, user_data);
@@ -265,7 +253,6 @@ firmware_load_update_settings (MMIfaceModemFirmware *self,
NULL, NULL,
(GAsyncReadyCallback)foxconn_get_firmware_version_over_fox_service_ready, (GAsyncReadyCallback)foxconn_get_firmware_version_over_fox_service_ready,
task); task);
qmi_message_fox_get_firmware_version_input_unref (input);
} }
#endif #endif