aboutsummaryrefslogtreecommitdiff
path: root/src/mm-iface-modem-firmware.c
diff options
context:
space:
mode:
authorDylan Van Assche <me@dylanvanassche.be>2022-02-06 18:47:24 +0100
committerDylan Van Assche <me@dylanvanassche.be>2022-02-08 19:33:56 +0100
commit90397fa1bbae2297aca169f8fbfa981fa0f5d4e6 (patch)
tree3f608612b0681484d9d52eb3c1031f4c9282016c /src/mm-iface-modem-firmware.c
parentbdf4d898f6a490ce2c1c9dc41871c4baced1e37b (diff)
iface-modem-firmware: expose device id builder
Expose the generic device id method as a public API for plugins. Plugins can call this method first and then add their own device ids on top in case the generic ones aren't specific enough like in the case of Quectel modems.
Diffstat (limited to 'src/mm-iface-modem-firmware.c')
-rw-r--r--src/mm-iface-modem-firmware.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/mm-iface-modem-firmware.c b/src/mm-iface-modem-firmware.c
index 1b4a07ad..fe1feb1d 100644
--- a/src/mm-iface-modem-firmware.c
+++ b/src/mm-iface-modem-firmware.c
@@ -325,10 +325,9 @@ add_generic_version (MMBaseModem *self,
return TRUE;
}
-static gboolean
-add_generic_device_ids (MMBaseModem *self,
- MMFirmwareUpdateSettings *update_settings,
- GError **error)
+GPtrArray *
+mm_iface_firmware_build_generic_device_ids (MMIfaceModemFirmware *self,
+ GError **error)
{
static const gchar *supported_subsystems[] = { "USB", "PCI" };
guint16 vid;
@@ -341,8 +340,8 @@ add_generic_device_ids (MMBaseModem *self,
guint i;
gboolean ignore_carrier = FALSE;
- vid = mm_base_modem_get_vendor_id (self);
- pid = mm_base_modem_get_product_id (self);
+ vid = mm_base_modem_get_vendor_id (MM_BASE_MODEM (self));
+ pid = mm_base_modem_get_product_id (MM_BASE_MODEM (self));
#if defined WITH_QMI
if (MM_IS_BROADBAND_MODEM_QMI (self))
@@ -353,16 +352,15 @@ add_generic_device_ids (MMBaseModem *self,
primary = MM_PORT (mm_broadband_modem_mbim_peek_port_mbim (MM_BROADBAND_MODEM_MBIM (self)));
#endif
if (!primary)
- primary = MM_PORT (mm_base_modem_peek_port_primary (self));
+ primary = MM_PORT (mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)));
g_assert (primary != NULL);
rid = mm_kernel_device_get_physdev_revision (mm_port_peek_kernel_device (primary));
-
subsystem = mm_kernel_device_get_physdev_subsystem (mm_port_peek_kernel_device (primary));
if (!subsystem) {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Unknown device subsystem");
- return FALSE;
+ return NULL;
}
for (i = 0; i < G_N_ELEMENTS (supported_subsystems); i++) {
@@ -372,7 +370,7 @@ add_generic_device_ids (MMBaseModem *self,
if (i == G_N_ELEMENTS (supported_subsystems)) {
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Unsupported subsystem: %s", subsystem);
- return FALSE;
+ return NULL;
}
g_object_get (self,
@@ -398,8 +396,7 @@ add_generic_device_ids (MMBaseModem *self,
supported_subsystems[i], vid));
g_ptr_array_add (ids, NULL);
- mm_firmware_update_settings_set_device_ids (update_settings, (const gchar **)ids->pdata);
- return TRUE;
+ return g_steal_pointer (&ids);
}
static void
@@ -411,6 +408,7 @@ load_update_settings_ready (MMIfaceModemFirmware *self,
MMFirmwareUpdateSettings *update_settings;
GError *error = NULL;
GVariant *variant = NULL;
+ g_autoptr(GPtrArray) ids = NULL;
ctx = g_task_get_task_data (task);
@@ -422,12 +420,17 @@ load_update_settings_ready (MMIfaceModemFirmware *self,
}
/* If the plugin didn't specify custom device ids, add the default ones ourselves */
- if (!mm_firmware_update_settings_get_device_ids (update_settings) &&
- !add_generic_device_ids (MM_BASE_MODEM (self), update_settings, &error)) {
- mm_obj_warn (self, "couldn't build device ids: %s", error->message);
- g_error_free (error);
- g_clear_object (&update_settings);
- goto out;
+ if (!mm_firmware_update_settings_get_device_ids (update_settings)) {
+ mm_obj_dbg (self, "No device ids set by plugin, adding generic ids");
+ ids = mm_iface_firmware_build_generic_device_ids (self, &error);
+ if (error) {
+ mm_obj_warn (self, "couldn't build device ids: %s", error->message);
+ g_error_free (error);
+ g_clear_object (&update_settings);
+ goto out;
+ }
+
+ mm_firmware_update_settings_set_device_ids (update_settings, (const gchar **)ids->pdata);
}
/* If the plugin didn't specify custom version, add the default one ourselves */