foxconn: consolidate logic deciding requested firmware version type

We don't want to have in two different places the vid:pid match list
when selecting the type of firmware version we ask for.
This commit is contained in:
Aleksander Morgado
2022-03-25 14:12:58 +01:00
parent 4efb5f61cf
commit b16b49f9d5

View File

@@ -82,9 +82,9 @@ firmware_load_update_settings_finish (MMIfaceModemFirmware *self,
} }
static void static void
foxconn_get_firmware_version_over_dms_service_ready (QmiClientDms *client, dms_foxconn_get_firmware_version_ready (QmiClientDms *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionOutput) output = NULL; g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionOutput) output = NULL;
GError *error = NULL; GError *error = NULL;
@@ -124,9 +124,9 @@ foxconn_get_firmware_version_over_dms_service_ready (QmiClientDms *client,
} }
static void static void
foxconn_get_firmware_version_over_fox_service_ready (QmiClientFox *client, fox_get_firmware_version_ready (QmiClientFox *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
g_autoptr(QmiMessageFoxGetFirmwareVersionOutput) output = NULL; g_autoptr(QmiMessageFoxGetFirmwareVersionOutput) output = NULL;
GError *error = NULL; GError *error = NULL;
@@ -166,93 +166,73 @@ foxconn_get_firmware_version_over_fox_service_ready (QmiClientFox *client,
g_object_unref (task); g_object_unref (task);
} }
static void
firmware_load_update_settings_over_dms_service (MMIfaceModemFirmware *self,
GTask *task)
{
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,
MM_PORT_QMI_FLAG_DEFAULT,
NULL);
if (!client) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Unable to load version info: no QMI FOX and DMS client available");
g_object_unref (task);
return;
}
vendor_id = mm_base_modem_get_vendor_id (MM_BASE_MODEM (self));
product_id = mm_base_modem_get_product_id (MM_BASE_MODEM (self));
input = qmi_message_dms_foxconn_get_firmware_version_input_new ();
/* 0x105b is the T99W175 module, T99W175/T99W265 need to compare the apps version. */
if (vendor_id == 0x105b || (vendor_id == 0x0489 && (product_id == 0xe0da || product_id == 0xe0db)))
qmi_message_dms_foxconn_get_firmware_version_input_set_version_type (
input,
QMI_DMS_FOXCONN_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG_APPS,
NULL);
else
qmi_message_dms_foxconn_get_firmware_version_input_set_version_type (
input,
QMI_DMS_FOXCONN_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG,
NULL);
qmi_client_dms_foxconn_get_firmware_version (
QMI_CLIENT_DMS (client),
input,
10,
NULL,
(GAsyncReadyCallback)foxconn_get_firmware_version_over_dms_service_ready,
task);
}
static void static void
firmware_load_update_settings (MMIfaceModemFirmware *self, firmware_load_update_settings (MMIfaceModemFirmware *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GTask *task; GTask *task;
g_autoptr(QmiMessageFoxGetFirmwareVersionInput) input = NULL; QmiFoxFirmwareVersionType fox_version_type;
QmiClient *client = NULL; QmiClient *fox_client = NULL;
guint vendor_id; QmiDmsFoxconnFirmwareVersionType dms_version_type;
guint product_id; QmiClient *dms_client = NULL;
guint vendor_id;
guint product_id;
task = g_task_new (self, NULL, callback, user_data); task = g_task_new (self, NULL, callback, user_data);
/* 0x105b is the T99W175 module, T99W175/T99W265 need to compare the apps version. */
vendor_id = mm_base_modem_get_vendor_id (MM_BASE_MODEM (self));
product_id = mm_base_modem_get_product_id (MM_BASE_MODEM (self));
if (vendor_id == 0x105b || (vendor_id == 0x0489 && (product_id == 0xe0da || product_id == 0xe0db))) {
fox_version_type = QMI_FOX_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG_APPS;
dms_version_type = QMI_DMS_FOXCONN_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG_APPS;
} else {
fox_version_type = QMI_FOX_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG;
dms_version_type = QMI_DMS_FOXCONN_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG;
}
/* Try to get firmware version over fox service, if it failed to peek client, try dms service. */ /* Try to get firmware version over fox service, if it failed to peek client, try dms service. */
client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self), fox_client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_FOX, MM_PORT_QMI_FLAG_DEFAULT, NULL);
QMI_SERVICE_FOX, if (!fox_client) {
MM_PORT_QMI_FLAG_DEFAULT, dms_client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self), QMI_SERVICE_DMS, MM_PORT_QMI_FLAG_DEFAULT, NULL);
NULL); if (!dms_client) {
if (!client) { g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
firmware_load_update_settings_over_dms_service (self, task); "Unable to load version info: no FOX or DMS client available");
g_object_unref (task);
return;
}
}
if (fox_client) {
g_autoptr(QmiMessageFoxGetFirmwareVersionInput) input = NULL;
input = qmi_message_fox_get_firmware_version_input_new ();
qmi_message_fox_get_firmware_version_input_set_version_type (input, fox_version_type, NULL);
qmi_client_fox_get_firmware_version (QMI_CLIENT_FOX (fox_client),
input,
10,
NULL,
(GAsyncReadyCallback)fox_get_firmware_version_ready,
task);
return; return;
} }
vendor_id = mm_base_modem_get_vendor_id (MM_BASE_MODEM (self)); if (dms_client) {
product_id = mm_base_modem_get_product_id (MM_BASE_MODEM (self)); g_autoptr(QmiMessageDmsFoxconnGetFirmwareVersionInput) input = NULL;
input = qmi_message_fox_get_firmware_version_input_new ();
/* 0x105b is the T99W175 module, T99W175/T99W265 need to compare the apps version. */ input = qmi_message_dms_foxconn_get_firmware_version_input_new ();
if (vendor_id == 0x105b || (vendor_id == 0x0489 && (product_id == 0xe0da || product_id == 0xe0db))) qmi_message_dms_foxconn_get_firmware_version_input_set_version_type (input, dms_version_type, NULL);
qmi_message_fox_get_firmware_version_input_set_version_type ( qmi_client_dms_foxconn_get_firmware_version (QMI_CLIENT_DMS (dms_client),
input, input,
QMI_FOX_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG_APPS, 10,
NULL); NULL,
else (GAsyncReadyCallback)dms_foxconn_get_firmware_version_ready,
qmi_message_fox_get_firmware_version_input_set_version_type ( task);
input, return;
QMI_FOX_FIRMWARE_VERSION_TYPE_FIRMWARE_MCFG, }
NULL);
qmi_client_fox_get_firmware_version ( g_assert_not_reached ();
QMI_CLIENT_FOX (client),
input,
10,
NULL,
(GAsyncReadyCallback)foxconn_get_firmware_version_over_fox_service_ready,
task);
} }
#endif #endif