diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-12-27 08:47:49 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-12-27 08:53:45 +0100 |
commit | c8fcf7a91d5d9f4d5d0942a3b07984e330198d10 (patch) | |
tree | b68338ab76053abf84c91b9857fc325c8915ecab /src/mm-plugin.c | |
parent | 7da2a65b43a386499bd5df66dba53f4b31417cad (diff) | |
download | ModemManager-c8fcf7a91d5d9f4d5d0942a3b07984e330198d10.tar.gz |
plugin: re-run subsystems filter before grabbing the ports
Every port probing will have the Generic plugin as fallback, and due to some
other issues in other plugins (see ee099fcd), we need to allow overwriting the
suggested plugin from the Generic to a more specific one.
One of the drawbacks of this is that we're actually allowing the Generic plugin
to probe and accept the port, which means that the generic plugin may accept a
specific port type (e.g. QMI) while the specific plugin wouldn't. So, we will
now also run the subsystems filter before grabbing the specific port, in order
to really filter out those cases. We still keep the subsystems filter in
pre-probing, so that we build a better initial plugin list to probe.
Diffstat (limited to 'src/mm-plugin.c')
-rw-r--r-- | src/mm-plugin.c | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/src/mm-plugin.c b/src/mm-plugin.c index 5069f0ee0..b3e85d7bb 100644 --- a/src/mm-plugin.c +++ b/src/mm-plugin.c @@ -157,6 +157,33 @@ is_virtual_port (const gchar *device_name) /* Returns TRUE if the support check request was filtered out */ static gboolean +apply_subsystem_filter (MMPlugin *self, + GUdevDevice *port) +{ + if (self->priv->subsystems) { + const gchar *subsys; + guint i; + + subsys = g_udev_device_get_subsystem (port); + for (i = 0; self->priv->subsystems[i]; i++) { + if (g_str_equal (subsys, self->priv->subsystems[i])) + break; + /* New kernels may report as 'usbmisc' the subsystem */ + else if (g_str_equal (self->priv->subsystems[i], "usb") && + g_str_equal (subsys, "usbmisc")) + break; + } + + /* If we didn't match any subsystem: unsupported */ + if (!self->priv->subsystems[i]) + return TRUE; + } + + return FALSE; +} + +/* Returns TRUE if the support check request was filtered out */ +static gboolean apply_pre_probing_filters (MMPlugin *self, MMDevice *device, GUdevDevice *port, @@ -174,26 +201,11 @@ apply_pre_probing_filters (MMPlugin *self, /* The plugin may specify that only some subsystems are supported. If that * is the case, filter by subsystem */ - if (self->priv->subsystems) { - const gchar *subsys; - - subsys = g_udev_device_get_subsystem (port); - for (i = 0; self->priv->subsystems[i]; i++) { - if (g_str_equal (subsys, self->priv->subsystems[i])) - break; - /* New kernels may report as 'usbmisc' the subsystem */ - else if (g_str_equal (self->priv->subsystems[i], "usb") && - g_str_equal (subsys, "usbmisc")) - break; - } - - /* If we didn't match any subsystem: unsupported */ - if (!self->priv->subsystems[i]) { - mm_dbg ("(%s) [%s] filtered by subsystem", - self->priv->name, - g_udev_device_get_name (port)); - return TRUE; - } + if (apply_subsystem_filter (self, port)) { + mm_dbg ("(%s) [%s] filtered by subsystem", + self->priv->name, + g_udev_device_get_name (port)); + return TRUE; } /* The plugin may specify that only some drivers are supported, or that some @@ -799,7 +811,16 @@ mm_plugin_create_modem (MMPlugin *self, /* If grabbing a port fails, just warn. We'll decide if the modem is * valid or not when all ports get organized */ - if (MM_PLUGIN_GET_CLASS (self)->grab_port) + /* We apply again the subsystem filter, as the port may have been + * probed and accepted by the generic plugin, which is overwritten + * by the specific one when needed. */ + if (apply_subsystem_filter (self, mm_port_probe_peek_port (probe))) { + grabbed = FALSE; + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "unsupported subsystem: '%s'", + mm_port_probe_get_port_subsys (probe)); + } else if (MM_PLUGIN_GET_CLASS (self)->grab_port) grabbed = MM_PLUGIN_GET_CLASS (self)->grab_port (MM_PLUGIN (self), modem, probe, |