Load partially USB composite device

Bjørn Mork bjorn at mork.no
Wed Aug 9 03:25:13 EDT 2017


loïc tourlonias <loic.tourlonias at gmail.com> writes:

> Hi everybody,
>
> In my project I have an USB composite device (a LTE modem) which use
> USB to communicate with the processor. This device has several
> interface to communicate but I do not use all of them. In particular,
> it loads cdc_ether device which I don't use and I have an undesired
> ethXX which interferes with a service in my system.

Sounds like your system has other issues, but whatever...

> To schematize, let's say my device is loaded on port 2 of usb1, I have
> the following USB topology:
> - 1-2:1.0: tty
> - 1-2:1.1: tty
> - 1-2:1.2: tty
> - 1-2:1.3: tty
> - 1-2:1.4: tty
> - 1-2:1.5: eth (not desired)
>
> Is there a way to prevent this specific ethXX to mount?
>
> I've already tried to create a udev rules, but I don't manage to stop
> the loading process.
> Here is a summary of my tries:
> 1/ I couldn't use the /sys/bus/usb1/.../1-2/activated file in my udev
> rule because it's an USB composite device and I want to use the tty
> interfaces but not the eth interface
>
> 2/ I have tried to stop the udev loading process, but setting MODALIAS
> environment variable to a NULL-string doesn(t do the trick and
> last-rule udev option has been removed in my udev version (1.8.2).
>
> 3/ I have tried to create a custom environment variable IGNORE_ETH and
> modify my last rule which run modprobe with the modalias variable. In
> the logs I see that modprobe isn't called by udev rules, but the
> cdc_ether device is loaded all the same.
>
> 4/ I have think of creating a stub cdc_ether driver and use the
> /etc/modprobe.d/my_file.conf to preempt the loading for my specific
> usb composite device but this solution is ugly and I'm not sure it
> will work.

The cdc_ether driver treats any ID entry with .driver_info = 0 as a
blacklist entry.  So you can dynamically blacklist devices by writing
the "VID PID" to /sys/bus/usb/drivers/cdc_ether/new_id before the device
is probed.


Bjørn



More information about the Kernelnewbies mailing list