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.
This commit is contained in:
@@ -155,6 +155,33 @@ is_virtual_port (const gchar *device_name)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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 */
|
/* Returns TRUE if the support check request was filtered out */
|
||||||
static gboolean
|
static gboolean
|
||||||
apply_pre_probing_filters (MMPlugin *self,
|
apply_pre_probing_filters (MMPlugin *self,
|
||||||
@@ -174,27 +201,12 @@ apply_pre_probing_filters (MMPlugin *self,
|
|||||||
|
|
||||||
/* The plugin may specify that only some subsystems are supported. If that
|
/* The plugin may specify that only some subsystems are supported. If that
|
||||||
* is the case, filter by subsystem */
|
* is the case, filter by subsystem */
|
||||||
if (self->priv->subsystems) {
|
if (apply_subsystem_filter (self, port)) {
|
||||||
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",
|
mm_dbg ("(%s) [%s] filtered by subsystem",
|
||||||
self->priv->name,
|
self->priv->name,
|
||||||
g_udev_device_get_name (port));
|
g_udev_device_get_name (port));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* The plugin may specify that only some drivers are supported, or that some
|
/* The plugin may specify that only some drivers are supported, or that some
|
||||||
* drivers are not supported. If that is the case, filter by driver */
|
* drivers are not supported. If that is the case, filter by driver */
|
||||||
@@ -799,7 +811,16 @@ mm_plugin_create_modem (MMPlugin *self,
|
|||||||
/* If grabbing a port fails, just warn. We'll decide if the modem is
|
/* If grabbing a port fails, just warn. We'll decide if the modem is
|
||||||
* valid or not when all ports get organized */
|
* 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),
|
grabbed = MM_PLUGIN_GET_CLASS (self)->grab_port (MM_PLUGIN (self),
|
||||||
modem,
|
modem,
|
||||||
probe,
|
probe,
|
||||||
|
Reference in New Issue
Block a user