[PATCH] broadband-modem-qmi: allow prefix match for Modem images ending with '?'
Dan Williams
dcbw at redhat.com
Wed Jun 14 20:20:09 UTC 2017
Assume that a modem image build_id "02.08.02.00_?" matches a pri build_id
of "02.08.02.00_ATT" or "02.08.02.00_GENERIC".
---
src/mm-broadband-modem-qmi.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 8390b6f..0e060d9 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -10151,6 +10151,28 @@ get_next_image_info (FirmwareCheckSupportContext *ctx)
qmi_message_dms_get_stored_image_info_input_unref (input);
}
+static gboolean
+match_images (const gchar *pri_id, const gchar *modem_id)
+{
+ gsize modem_id_len;
+
+ if (!pri_id || !modem_id)
+ return FALSE;
+
+ if (g_str_equal (pri_id, modem_id))
+ return TRUE;
+
+ /* If the Modem image build_id ends in '?' just use a prefix match. eg,
+ * assume that modem="02.08.02.00_?" matches pri="02.08.02.00_ATT" or
+ * pri="02.08.02.00_GENERIC".
+ */
+ modem_id_len = strlen (modem_id);
+ if (modem_id[modem_id_len - 1] != '?')
+ return FALSE;
+
+ return strncmp (pri_id, modem_id, modem_id_len - 1) == 0;
+}
+
static void
list_stored_images_ready (QmiClientDms *client,
GAsyncResult *res,
@@ -10241,7 +10263,7 @@ list_stored_images_ready (QmiClientDms *client,
QmiMessageDmsListStoredImagesOutputListImageSublistSublistElement,
j);
- if (g_str_equal (subimage_pri->build_id, subimage_modem->build_id)) {
+ if (match_images (subimage_pri->build_id, subimage_modem->build_id)) {
FirmwarePair *pair;
mm_dbg ("Found pairing PRI+MODEM images with build ID '%s'", subimage_pri->build_id);
--
2.9.4
More information about the ModemManager-devel
mailing list