Ubuntu – How to identify the module supposed to claim a device by vendor/product ID only

kernel

Suppose I know the numerical product/vendor IDs of hardware I don't have here and I want to know if there's support for me in the kernel, I can do this (USB bluetooth receiver example):

modinfo btusb
filename:       /lib/modules/3.7.5-030705-generic/kernel/drivers/bluetooth/btusb.ko
[...]
alias:          usb:v0A5Cp*d*dc*dsc*dp*icFFisc01ip01in*
alias:          usb:v0489p*d*dc*dsc*dp*icFFisc01ip01in*
alias:          usb:v413Cp8197d*dc*dsc*dp*ic*isc*ip*in*
[...]

From this I can see which devices are to be claimed by btusb and it requires me to know the module name on beforehand. In some cases however, I don't have a clue about the module(s) name(s) supporting such a device.

Networking hardware is one of those categories which seems very hard to find out about. Also, the lspci and lsusb names are sometimes inconclusive or simply wrong. I'm currently grepping through the whole kernel source tree, which is not that elegant.

  • Is there a way to list all modaliases of all modules (including built-in to the kernel) in one go so I can find a match?
  • Or, alternatively, is there a way to query the kernel to provide me the kernel modules claiming such a device I don't actually own?

Use cases:

  • Users asking questions here which I can answer/dupe with by actually verifying that "support is in if you upgrade to…" or "Try rmmod module1; modprobe module2 as module2 seems to support your device as well."
  • Checking support before buying hardware with prior knowledge of the IDs. Additional to searching with the IDs, I can then look for bug reports on the kernel module itself.

Best Answer

If you restate the problem as "How can I run modinfo on all (or some) modules and select some of the output for further use?", you could use this trick (I've left the commands I used to figure out how to get to the final result):

ls /lib/modules
ls /lib/modules/$(uname -r)
ls /lib/modules/$(uname -r)/kernel
find  /lib/modules/$(uname -r)/kernel -type f -name '*.ko' -print
for i in $( !! ) ; do
for i in $( find  /lib/modules/$(uname -r)/kernel -type f -name '*.ko' -print ) ; do
   j=${i##.*/}
   j=${j%%.ko}
   echo $j
   modinfo $i | egrep 'filename:|alias:'
   echo ""
   done

This trick can be used elsewhere, have fun!

Related Question