I have several USB modems that each have several endpoints: lot of TTYs, a network interface, a cdc-wdm port, and some other things. I'm trying to group them together so that I know, for instance, ttyUSB3, ttyUSB4, wwan1, and cdc-wdm1 all belong to the same physical USB device.

I thought $id was supposed to identify the physical device, so I tried adding $id to the environment with ENV{id}=$id. This seems to work for the network interfaces and serial ports, but not the cdc-wdm ports (id is unset for these ports).

1 Answer
1

The name of the device matched while searching the devpath upwards for SUBSYSTEMS, KERNELS, DRIVERS and ATTRS.

...and it's not what I thought (which was formed by failing to understand the documentation combined with some experimentation).

By "The name of the device", it's talking about the same thing the KERNEL key matches. The documentation says about the KERNEL key is:

Match the name of the event device.

That is how you know "name" and "KERNEL" are related.

The "matched while searching the devpath upwards for SUBSYSTEMS, KERNELS, DRIVERS and ATTRS" part means that if you specified a "SUBSYSTEMS, KERNELS, DRIVERS, or ATTRS" match in the rule, it will walk up the device tree until it finds a match; the name of the matched device will be used.

So, in my first rule, it was matching with the ATTRS key, and that device happened to be the physical USB device.

Now for my other rule, I had to look at the tree and find something that would match the physical device but not anything below it. Here is my device tree:

The device I want to match is /devices/platform/atmel-ehci/usb1/1-1/1-1.7/1-1.7.2'. You can see that the DRIVERS for that device is 'usb' and nothing below it will match that. The following rule solves my problem, should even be a generic solution since I'm pretty sure no endpoint of a device would be handled by the usb driver.