aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2014-09-05 09:33:38 +0200
committerAleksander Morgado <aleksander@aleksander.es>2014-09-05 09:54:55 +0200
commit31f81725e628fd94233e62752ec386215d2b9e13 (patch)
tree5a45830de07c59af8d638b9a7d9e1cf905635350
parent8450e563bb79bd1e300bba1d2e89c6d39a173694 (diff)
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.
-rw-r--r--src/mm-plugin.c13
-rw-r--r--src/mm-port-probe.c26
-rw-r--r--src/mm-port-probe.h1
3 files changed, 37 insertions, 3 deletions
diff --git a/src/mm-plugin.c b/src/mm-plugin.c
index f1f3796e..2b4adeab 100644
--- a/src/mm-plugin.c
+++ b/src/mm-plugin.c
@@ -865,6 +865,19 @@ mm_plugin_create_modem (MMPlugin *self,
"unsupported subsystem: '%s'",
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
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)),
diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c
index b25663f5..52096678 100644
--- a/src/mm-port-probe.c
+++ b/src/mm-port-probe.c
@@ -135,6 +135,9 @@ struct _MMPortProbePrivate {
gboolean is_qmi;
gboolean is_mbim;
+ /* From udev tags */
+ gboolean is_ignored;
+
/* Current probing task. Only one can be available at a time */
PortProbeRunTask *task;
};
@@ -1404,7 +1407,9 @@ mm_port_probe_list_has_at_port (GList *list)
for (l = list; l; l = g_list_next (l)){
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)
return TRUE;
}
@@ -1456,7 +1461,10 @@ mm_port_probe_list_has_qmi_port (GList *list)
GList *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;
}
@@ -1487,7 +1495,10 @@ mm_port_probe_list_has_mbim_port (GList *list)
GList *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;
}
@@ -1631,6 +1642,14 @@ mm_port_probe_list_is_icera (GList *probes)
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 *
mm_port_probe_get_port_name (MMPortProbe *self)
{
@@ -1692,6 +1711,7 @@ set_property (GObject *object,
/* construct only */
self->priv->port = g_value_dup_object (value);
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;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
diff --git a/src/mm-port-probe.h b/src/mm-port-probe.h
index ea7c98da..0b3226a0 100644
--- a/src/mm-port-probe.h
+++ b/src/mm-port-probe.h
@@ -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_product (MMPortProbe *self);
gboolean mm_port_probe_is_icera (MMPortProbe *self);
+gboolean mm_port_probe_is_ignored (MMPortProbe *self);
/* Additional helpers */
gboolean mm_port_probe_list_has_at_port (GList *list);