plugin: refactor how list of probe flags is built

To make it clearer that the initial list of flags must be the one
based on which ones are expected in the subsystem and which one the
plugin is requesting.
This commit is contained in:
Aleksander Morgado
2023-03-28 10:09:21 +00:00
parent cb2dea5dc4
commit 79b15cf87c

View File

@@ -759,6 +759,8 @@ mm_plugin_supports_port (MMPlugin *self,
PortProbeRunContext *ctx; PortProbeRunContext *ctx;
gboolean need_vendor_probing; gboolean need_vendor_probing;
gboolean need_product_probing; gboolean need_product_probing;
MMPortProbeFlag subsystem_expected_flags;
MMPortProbeFlag plugin_expected_flags;
MMPortProbeFlag probe_run_flags; MMPortProbeFlag probe_run_flags;
gchar *probe_list_str; gchar *probe_list_str;
@@ -797,44 +799,35 @@ mm_plugin_supports_port (MMPlugin *self,
return; return;
} }
/* Build flags depending on what probing is requested by the plugin */ /* Build mask of flags based on subsystem */
probe_run_flags = MM_PORT_PROBE_NONE; subsystem_expected_flags = MM_PORT_PROBE_NONE;
if (g_str_equal (mm_kernel_device_get_subsystem (port), "tty")) { if (g_str_equal (mm_kernel_device_get_subsystem (port), "tty"))
if (self->priv->at) subsystem_expected_flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_QCDM);
probe_run_flags |= MM_PORT_PROBE_AT; else if (g_str_equal (mm_kernel_device_get_subsystem (port), "usbmisc"))
else if (self->priv->single_at) subsystem_expected_flags |= (MM_PORT_PROBE_QMI | MM_PORT_PROBE_MBIM | MM_PORT_PROBE_AT);
probe_run_flags |= MM_PORT_PROBE_AT; else if (g_str_equal (mm_kernel_device_get_subsystem (port), "rpmsg"))
if (self->priv->qcdm || self->priv->qcdm_required) subsystem_expected_flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_QMI);
probe_run_flags |= MM_PORT_PROBE_QCDM; else if (g_str_equal (mm_kernel_device_get_subsystem (port), "wwan"))
} else if (g_str_equal (mm_kernel_device_get_subsystem (port), "usbmisc")) { subsystem_expected_flags |= (MM_PORT_PROBE_QMI | MM_PORT_PROBE_MBIM | MM_PORT_PROBE_AT | MM_PORT_PROBE_QCDM);
if (self->priv->qmi)
probe_run_flags |= MM_PORT_PROBE_QMI;
if (self->priv->mbim)
probe_run_flags |= MM_PORT_PROBE_MBIM;
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)
probe_run_flags |= MM_PORT_PROBE_AT;
if (self->priv->qmi)
probe_run_flags |= MM_PORT_PROBE_QMI;
} else if (g_str_equal (mm_kernel_device_get_subsystem (port), "wwan")) {
if (self->priv->mbim)
probe_run_flags |= MM_PORT_PROBE_MBIM;
if (self->priv->qmi)
probe_run_flags |= MM_PORT_PROBE_QMI;
if (self->priv->qcdm || self->priv->qcdm_required)
probe_run_flags |= MM_PORT_PROBE_QCDM;
if (self->priv->at)
probe_run_flags |= MM_PORT_PROBE_AT;
}
#if defined WITH_QRTR #if defined WITH_QRTR
else if (g_str_equal (mm_kernel_device_get_subsystem (port), "qrtr")) { else if (g_str_equal (mm_kernel_device_get_subsystem (port), "qrtr"))
if (self->priv->qmi) subsystem_expected_flags |= MM_PORT_PROBE_QMI;
probe_run_flags |= MM_PORT_PROBE_QMI;
}
#endif #endif
/* Build mask of flags based on plugin */
plugin_expected_flags = MM_PORT_PROBE_NONE;
if (self->priv->at)
plugin_expected_flags |= MM_PORT_PROBE_AT;
if (self->priv->qcdm || self->priv->qcdm_required)
plugin_expected_flags |= MM_PORT_PROBE_QCDM;
if (self->priv->qmi)
plugin_expected_flags |= MM_PORT_PROBE_QMI;
if (self->priv->mbim)
plugin_expected_flags |= MM_PORT_PROBE_MBIM;
/* Initial list of probe flags based on plugin and subsystem */
probe_run_flags = subsystem_expected_flags & plugin_expected_flags;
/* For potential AT ports, check for more things */ /* For potential AT ports, check for more things */
if (probe_run_flags & MM_PORT_PROBE_AT) { if (probe_run_flags & MM_PORT_PROBE_AT) {
if (need_vendor_probing) if (need_vendor_probing)