# How to identify the module supposed to claim a device by vendor/product ID only?

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.
-
There isn't really an easy way to get this information. Not all USB devices are claimed based on their IDs. Class based devices (storage, HID, and many serial and networking devices) are identified based on what interface they provide. –  Alistair Buxton Feb 10 '13 at 4:27
maybe usb-modeswitch can help with that. if you not have it: sudo apt-get install usb-modeswitch –  Dimitris Theodoridis Mar 26 '13 at 2:17
type lsusb and you will see ID –  Dimitris Theodoridis Mar 26 '13 at 2:39
from your question i just saw that you want to see id and change it, am i wrong? –  Dimitris Theodoridis Mar 26 '13 at 3:01
now i really not understand you. please explain your question than i can understand it better and see if i actually can help you –  Dimitris Theodoridis Mar 26 '13 at 3:25

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$j | egrep 'filename:|alias:'
echo ""
done


This trick can be used elsewhere, have fun!

-