plugin: allow to explicitly ignore any kind of port via udev
The new 'ID_MM_PORT_IGNORE' tag will tell ModemManager to fully avoid using a given port. Note that it is key to not only flag the port probe as ignored, but also to fully ignore the ports in e.g. mm_port_probe_list_has_qmi_port() as those methods will be used to decide which kind of modem object to create. We don't want to create a QMI-based modem which may have all QMI ports blacklisted.
This commit is contained in:
@@ -865,6 +865,19 @@ mm_plugin_create_modem (MMPlugin *self,
|
|||||||
"unsupported subsystem: '%s'",
|
"unsupported subsystem: '%s'",
|
||||||
mm_port_probe_get_port_subsys (probe));
|
mm_port_probe_get_port_subsys (probe));
|
||||||
}
|
}
|
||||||
|
/* Ports that are explicitly blacklisted will be grabbed as ignored */
|
||||||
|
else if (mm_port_probe_is_ignored (probe)) {
|
||||||
|
mm_dbg ("(%s/%s): port is blacklisted",
|
||||||
|
mm_port_probe_get_port_subsys (probe),
|
||||||
|
mm_port_probe_get_port_name (probe));
|
||||||
|
grabbed = mm_base_modem_grab_port (modem,
|
||||||
|
mm_port_probe_get_port_subsys (probe),
|
||||||
|
mm_port_probe_get_port_name (probe),
|
||||||
|
mm_port_probe_get_parent_path (probe),
|
||||||
|
MM_PORT_TYPE_IGNORED,
|
||||||
|
MM_PORT_SERIAL_AT_FLAG_NONE,
|
||||||
|
&inner_error);
|
||||||
|
}
|
||||||
#if !defined WITH_QMI
|
#if !defined WITH_QMI
|
||||||
else if (mm_port_probe_get_port_type (probe) == MM_PORT_TYPE_NET &&
|
else if (mm_port_probe_get_port_type (probe) == MM_PORT_TYPE_NET &&
|
||||||
g_str_equal (mm_device_utils_get_port_driver (mm_port_probe_peek_port (probe)),
|
g_str_equal (mm_device_utils_get_port_driver (mm_port_probe_peek_port (probe)),
|
||||||
|
@@ -135,6 +135,9 @@ struct _MMPortProbePrivate {
|
|||||||
gboolean is_qmi;
|
gboolean is_qmi;
|
||||||
gboolean is_mbim;
|
gboolean is_mbim;
|
||||||
|
|
||||||
|
/* From udev tags */
|
||||||
|
gboolean is_ignored;
|
||||||
|
|
||||||
/* Current probing task. Only one can be available at a time */
|
/* Current probing task. Only one can be available at a time */
|
||||||
PortProbeRunTask *task;
|
PortProbeRunTask *task;
|
||||||
};
|
};
|
||||||
@@ -1404,7 +1407,9 @@ mm_port_probe_list_has_at_port (GList *list)
|
|||||||
|
|
||||||
for (l = list; l; l = g_list_next (l)){
|
for (l = list; l; l = g_list_next (l)){
|
||||||
MMPortProbe *probe = MM_PORT_PROBE (l->data);
|
MMPortProbe *probe = MM_PORT_PROBE (l->data);
|
||||||
if (probe->priv->flags & MM_PORT_PROBE_AT &&
|
|
||||||
|
if (!probe->priv->is_ignored &&
|
||||||
|
probe->priv->flags & MM_PORT_PROBE_AT &&
|
||||||
probe->priv->is_at)
|
probe->priv->is_at)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -1456,7 +1461,10 @@ mm_port_probe_list_has_qmi_port (GList *list)
|
|||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
for (l = list; l; l = g_list_next (l)) {
|
for (l = list; l; l = g_list_next (l)) {
|
||||||
if (mm_port_probe_is_qmi (MM_PORT_PROBE (l->data)))
|
MMPortProbe *probe = MM_PORT_PROBE (l->data);
|
||||||
|
|
||||||
|
if (!probe->priv->is_ignored &&
|
||||||
|
mm_port_probe_is_qmi (probe))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1487,7 +1495,10 @@ mm_port_probe_list_has_mbim_port (GList *list)
|
|||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
for (l = list; l; l = g_list_next (l)) {
|
for (l = list; l; l = g_list_next (l)) {
|
||||||
if (mm_port_probe_is_mbim (MM_PORT_PROBE (l->data)))
|
MMPortProbe *probe = MM_PORT_PROBE (l->data);
|
||||||
|
|
||||||
|
if (!probe->priv->is_ignored &&
|
||||||
|
mm_port_probe_is_mbim (probe))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1631,6 +1642,14 @@ mm_port_probe_list_is_icera (GList *probes)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
mm_port_probe_is_ignored (MMPortProbe *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
|
||||||
|
|
||||||
|
return self->priv->is_ignored;
|
||||||
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
mm_port_probe_get_port_name (MMPortProbe *self)
|
mm_port_probe_get_port_name (MMPortProbe *self)
|
||||||
{
|
{
|
||||||
@@ -1692,6 +1711,7 @@ set_property (GObject *object,
|
|||||||
/* construct only */
|
/* construct only */
|
||||||
self->priv->port = g_value_dup_object (value);
|
self->priv->port = g_value_dup_object (value);
|
||||||
self->priv->parent = g_udev_device_get_parent (self->priv->port);
|
self->priv->parent = g_udev_device_get_parent (self->priv->port);
|
||||||
|
self->priv->is_ignored = g_udev_device_get_property_as_boolean (self->priv->port, "ID_MM_PORT_IGNORE");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@@ -131,6 +131,7 @@ gboolean mm_port_probe_is_mbim (MMPortProbe *self);
|
|||||||
const gchar *mm_port_probe_get_vendor (MMPortProbe *self);
|
const gchar *mm_port_probe_get_vendor (MMPortProbe *self);
|
||||||
const gchar *mm_port_probe_get_product (MMPortProbe *self);
|
const gchar *mm_port_probe_get_product (MMPortProbe *self);
|
||||||
gboolean mm_port_probe_is_icera (MMPortProbe *self);
|
gboolean mm_port_probe_is_icera (MMPortProbe *self);
|
||||||
|
gboolean mm_port_probe_is_ignored (MMPortProbe *self);
|
||||||
|
|
||||||
/* Additional helpers */
|
/* Additional helpers */
|
||||||
gboolean mm_port_probe_list_has_at_port (GList *list);
|
gboolean mm_port_probe_list_has_at_port (GList *list);
|
||||||
|
Reference in New Issue
Block a user