diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2023-03-28 10:09:21 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2023-04-13 11:54:03 +0000 |
commit | 79b15cf87ce3d94a061f2f37eec2f00eb3987cc6 (patch) | |
tree | ed3c837d9a4dffca425f23527b099fbd475ef249 | |
parent | cb2dea5dc4d5617a1736f63c3986551825f1a385 (diff) | |
download | ModemManager-79b15cf87ce3d94a061f2f37eec2f00eb3987cc6.tar.gz |
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.
-rw-r--r-- | src/mm-plugin.c | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/src/mm-plugin.c b/src/mm-plugin.c index b4901fd89..725391fc2 100644 --- a/src/mm-plugin.c +++ b/src/mm-plugin.c @@ -759,6 +759,8 @@ mm_plugin_supports_port (MMPlugin *self, PortProbeRunContext *ctx; gboolean need_vendor_probing; gboolean need_product_probing; + MMPortProbeFlag subsystem_expected_flags; + MMPortProbeFlag plugin_expected_flags; MMPortProbeFlag probe_run_flags; gchar *probe_list_str; @@ -797,44 +799,35 @@ mm_plugin_supports_port (MMPlugin *self, return; } - /* 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) - probe_run_flags |= MM_PORT_PROBE_AT; - else if (self->priv->single_at) - probe_run_flags |= MM_PORT_PROBE_AT; - 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) - 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; - } + /* Build mask of flags based on subsystem */ + subsystem_expected_flags = MM_PORT_PROBE_NONE; + if (g_str_equal (mm_kernel_device_get_subsystem (port), "tty")) + subsystem_expected_flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_QCDM); + 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); + else if (g_str_equal (mm_kernel_device_get_subsystem (port), "rpmsg")) + subsystem_expected_flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_QMI); + else if (g_str_equal (mm_kernel_device_get_subsystem (port), "wwan")) + subsystem_expected_flags |= (MM_PORT_PROBE_QMI | MM_PORT_PROBE_MBIM | MM_PORT_PROBE_AT | MM_PORT_PROBE_QCDM); #if defined WITH_QRTR - else if (g_str_equal (mm_kernel_device_get_subsystem (port), "qrtr")) { - if (self->priv->qmi) - probe_run_flags |= MM_PORT_PROBE_QMI; - } + else if (g_str_equal (mm_kernel_device_get_subsystem (port), "qrtr")) + subsystem_expected_flags |= MM_PORT_PROBE_QMI; #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 */ if (probe_run_flags & MM_PORT_PROBE_AT) { if (need_vendor_probing) |