summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2023-03-28 08:18:45 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2023-04-13 11:53:03 +0000
commite77df40b68ce32980f307959cc98d31918690a81 (patch)
tree4bc2975ee65299db774a6751bae2d1f8317d221f
parent131e783a5f33f7a710f68203546bd0946a2504f8 (diff)
downloadModemManager-e77df40b68ce32980f307959cc98d31918690a81.tar.gz
port-probe: perform auto detection of port type hints for cdc_wdm
Do not do this in the plugin; instead, do it along with the logic that looks for port type hints in udev, so that we can properly warn if things don't match.
-rw-r--r--src/mm-plugin.c8
-rw-r--r--src/mm-port-probe.c54
2 files changed, 55 insertions, 7 deletions
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index 97dcbc44a..b4901fd89 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -797,7 +797,7 @@ mm_plugin_supports_port (MMPlugin *self,
return;
}
- /* Build flags depending on what probing needed */
+ /* Build flags depending on what probing is requested by the plugin */
probe_run_flags = MM_PORT_PROBE_NONE;
if (g_str_equal (mm_kernel_device_get_subsystem (port), "tty")) {
if (self->priv->at)
@@ -807,11 +807,11 @@ mm_plugin_supports_port (MMPlugin *self,
if (self->priv->qcdm || self->priv->qcdm_required)
probe_run_flags |= MM_PORT_PROBE_QCDM;
} else if (g_str_equal (mm_kernel_device_get_subsystem (port), "usbmisc")) {
- if (self->priv->qmi && !g_strcmp0 (mm_kernel_device_get_driver (port), "qmi_wwan"))
+ if (self->priv->qmi)
probe_run_flags |= MM_PORT_PROBE_QMI;
- else if (self->priv->mbim && !g_strcmp0 (mm_kernel_device_get_driver (port), "cdc_mbim"))
+ if (self->priv->mbim)
probe_run_flags |= MM_PORT_PROBE_MBIM;
- else
+ if (self->priv->at)
probe_run_flags |= MM_PORT_PROBE_AT;
} else if (g_str_equal (mm_kernel_device_get_subsystem (port), "rpmsg")) {
if (self->priv->at)
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index 1c338b9e4..67a1aca3b 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -1850,11 +1850,14 @@ initialize_port_type_hints (MMPortProbe *self)
{
g_autoptr(GString) udev_tags = NULL;
guint n_udev_hints = 0;
+ gboolean auto_maybe_qmi = FALSE;
+ gboolean auto_maybe_mbim = FALSE;
+ gboolean auto_maybe_at = FALSE;
#define ADD_HINT_FROM_UDEV_TAG(TAG, FIELD) do { \
if (!self->priv->FIELD && \
mm_kernel_device_get_property_as_boolean (self->priv->port, TAG)) { \
- mm_obj_dbg (self, "udev tag detected: %s", TAG); \
+ mm_obj_dbg (self, "port type hint detected in udev tag: %s", TAG); \
self->priv->FIELD = TRUE; \
n_udev_hints++; \
if (!udev_tags) \
@@ -1878,9 +1881,54 @@ initialize_port_type_hints (MMPortProbe *self)
if (n_udev_hints > 1)
mm_obj_warn (self, "multiple incompatible port type hints configured via udev: %s", udev_tags->str);
- ADD_HINT_FROM_UDEV_TAG (ID_MM_PORT_IGNORE, is_ignored);
+ /* Process automatic port type hints, and warn if the hint doesn't match the
+ * one provided via udev. The udev-provided hints are always preferred. */
+ if (!g_strcmp0 (mm_kernel_device_get_subsystem (self->priv->port), "usbmisc")) {
+ const gchar *driver;
+
+ driver = mm_kernel_device_get_driver (self->priv->port);
+ if (!g_strcmp0 (driver, "qmi_wwan")) {
+ mm_obj_dbg (self, "port may be QMI based on the driver in use");
+ auto_maybe_qmi = TRUE;
+ } else if (!g_strcmp0 (driver, "cdc_mbim")) {
+ mm_obj_dbg (self, "port may be MBIM based on the driver in use");
+ auto_maybe_mbim = TRUE;
+ } else {
+ mm_obj_dbg (self, "port may be AT based on the driver in use: %s", driver);
+ auto_maybe_at = TRUE;
+ }
+ }
+
+ g_assert ((auto_maybe_qmi + auto_maybe_mbim + auto_maybe_at) <= 1);
+
+#define PROCESS_AUTO_HINTS(TYPE, FIELD) do { \
+ if (auto_##FIELD) { \
+ if (n_udev_hints > 0 && !self->priv->FIELD) \
+ mm_obj_warn (self, "overriding type in possible " TYPE " port with udev tag: %s", udev_tags->str); \
+ else \
+ self->priv->FIELD = TRUE; \
+ } \
+ } while (0)
+
+ PROCESS_AUTO_HINTS ("QMI", maybe_qmi);
+ PROCESS_AUTO_HINTS ("MBIM", maybe_mbim);
+ PROCESS_AUTO_HINTS ("AT", maybe_at);
+
+#undef PROCESS_AUTO_HINTS
-#undef ADD_HINT_FROM_UDEV_TAG
+ mm_obj_dbg (self, "port type hints loaded: AT %s, QMI %s, MBIM %s, QCDM %s, AUDIO %s, GPS %s",
+ self->priv->maybe_at ? "yes" : "no",
+ self->priv->maybe_qmi ? "yes" : "no",
+ self->priv->maybe_mbim ? "yes" : "no",
+ self->priv->maybe_qcdm ? "yes" : "no",
+ self->priv->is_audio ? "yes" : "no",
+ self->priv->is_gps ? "yes" : "no");
+
+ /* Regardless of the type, the port may be ignored */
+ if (mm_kernel_device_get_property_as_boolean (self->priv->port, ID_MM_PORT_IGNORE)) {
+ mm_obj_dbg (self, "port is ignored via udev tag");
+ self->priv->is_ignored = TRUE;
+ }
}
/*****************************************************************************/