[PATCH 2/5] udevng: mhi: Collect WWAN net devices as well

Denis Kenzior <[email protected]> Fri, 9 May 2025 15:01:09 -0500
Newsgroups dev.linux.lists.ofono
Message-ID <[email protected]>
net devices that are part of the WWAN subsystem should be categorized as
part of the MHI device as well.  This is relevant for MHI devices that
operate in MBIM mode.  For such devices, the netdev has an intermediate
parent (the wwan device) instead of being parented directly to the MHI
subsystem device.

│ │ │ │ └─mhi0
│ │ │ │   ┆ P: /devices/pci0000:00/...
│ │ │ │   ┆ M: mhi0
│ │ │ │   ┆ R: 0
│ │ │ │   ┆ J: +mhi:mhi0
│ │ │ │   ┆ U: mhi
│ │ │ │   ┆ E: DEVPATH=/devices/pci0000:00/...
│ │ │ │   ┆ E: SUBSYSTEM=mhi
│ │ │ │   ┆ E: MODALIAS=mhi:mhi0
...
│ │ │ │   └─wwan/wwan0
│ │ │ │     ┆ P: /devices/pci0000:00/...
│ │ │ │     ┆ M: wwan0
│ │ │ │     ┆ R: 0
│ │ │ │     ┆ J: +wwan:wwan0
│ │ │ │     ┆ U: wwan
│ │ │ │     ┆ T: wwan_dev
│ │ │ │     ┆ E: DEVPATH=/devices/pci0000:00/...
│ │ │ │     ┆ E: SUBSYSTEM=wwan
│ │ │ │     ┆ E: DEVTYPE=wwan_dev
│ │ │ │     ├─net/wwan0
│ │ │ │     │ ┆ P: /devices/pci0000:00/...
│ │ │ │     │ ┆ M: wwan0
│ │ │ │     │ ┆ R: 0
│ │ │ │     │ ┆ J: n3
│ │ │ │     │ ┆ U: net
│ │ │ │     │ ┆ T: wwan
│ │ │ │     │ ┆ I: 3
│ │ │ │     │ ┆ E: DEVPATH=/devices/pci0000:00/...
│ │ │ │     │ ┆ E: SUBSYSTEM=net
│ │ │ │     │ ┆ E: DEVTYPE=wwan
│ │ │ │     │ ┆ E: INTERFACE=wwan0
│ │ │ │     │ ┆ E: IFINDEX=3
---
 plugins/udevng.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/plugins/udevng.c b/plugins/udevng.c
index 38de3df0f3c3..503c262abbff 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -2397,8 +2397,9 @@ static void check_net_device(struct udev_device *device)
 	const char *iflink;
 	struct udev_device *parent;
 
-	parent = udev_device_get_parent(device);
-	if (parent && l_streq0(udev_device_get_subsystem(parent), "mhi")) {
+	parent = udev_device_get_parent_with_subsystem_devtype(device,
+								"mhi", NULL);
+	if (parent) {
 		parent = udev_device_get_parent_with_subsystem_devtype(device,
 								"pci", NULL);
 		if (parent)
-- 
2.48.1