aboutsummaryrefslogtreecommitdiff
path: root/src/mm-device.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-02-12 12:29:49 +0100
committerAleksander Morgado <aleksander@aleksander.es>2021-03-10 12:58:12 +0100
commit897e48709d1f5238f5165a5e5ed42937b0784c80 (patch)
tree1431a6724c6314272975c893ebc273e2f4dea845 /src/mm-device.c
parent21174f289f1370c1badb10106045490604ccbdf4 (diff)
base-modem: allow grabbing link ports after modem is created
We will grab the ports and make them available through find_ports() or peek_port() or get_port(). The link ports are not 'organized' so they won't be available in e.g. get_data_ports(), which is fine, because we don't want to mix them with the real data ports exposed by the device. Link port additions and removals are also notified via signals in the modem object, so that explicit wait for specific ports can be done.
Diffstat (limited to 'src/mm-device.c')
-rw-r--r--src/mm-device.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/mm-device.c b/src/mm-device.c
index d0e31184..cfeb450b 100644
--- a/src/mm-device.c
+++ b/src/mm-device.c
@@ -211,11 +211,28 @@ void
mm_device_grab_port (MMDevice *self,
MMKernelDevice *kernel_port)
{
- MMPortProbe *probe;
+ MMPortProbe *probe;
+ MMKernelDevice *lower_port;
if (mm_device_owns_port (self, kernel_port))
return;
+ lower_port = mm_kernel_device_peek_lower_device (kernel_port);
+ if (lower_port) {
+ g_autoptr(GError) error = NULL;
+
+ /* No port probing done, at this point this is not something we require
+ * as all the virtual instantiated ports are net devices. We also avoid
+ * emitting the PORT_GRABBED signal in the MMDevice, because that is
+ * exclusively linked to a port being added to the list of probes, which
+ * we don't do here. */
+ if (self->priv->modem && !mm_base_modem_grab_link_port (self->priv->modem, kernel_port, &error))
+ mm_obj_dbg (self, "fully ignoring link port %s from now on: %s",
+ mm_kernel_device_get_name (kernel_port),
+ error->message);
+ return;
+ }
+
/* Get the vendor/product IDs out of the first one that gives us
* some valid value (it seems we may get NULL reported for VID in QMI
* ports, e.g. Huawei E367) */
@@ -242,6 +259,12 @@ mm_device_release_port_name (MMDevice *self,
{
MMPortProbe *probe;
+ /* If modem exists, try to remove it as a link port. We also avoid emitting
+ * the PORT_RELEASED signal in this case, as the link ports are not associated
+ * to the port probe list */
+ if (self->priv->modem && mm_base_modem_release_link_port (self->priv->modem, subsystem, name, NULL))
+ return;
+
probe = device_find_probe_with_name (self, subsystem, name);
if (probe) {
/* Found, remove from lists and destroy probe */