1 Title: Which module is loaded for a given PCI device?
5 <p>In the discover-data package in Debian, there is a script to report
6 useful information about the running hardware for use when people
7 report missing information. One part I find very useful when
8 debugging, is the part report which kernel module is loaded for a
9 given PCI device. To see the output, make sure discover-data is
10 installed and run <tt>/usr/share/bug/discover-data 3>&1</tt>. The
11 relevant output on one of my machines like this:
18 10de:03f0 snd_hda_intel
27 <p>The code in question look like this, slightly modified for
28 readability and to drop the output to file descriptor 3:</p>
31 if [ -d /sys/bus/pci/devices/ ] ; then
32 echo loaded pci modules:
34 cd /sys/bus/pci/devices/
36 if [ -d "$address/driver/module" ] ; then
37 module=`cd $address/driver/module ; pwd -P | xargs basename`
38 if grep -q "^$module " /proc/modules ; then
39 address=$(echo $address |sed s/0000://)
40 id=`lspci -n -s $address | tail -n 1 | awk '{print $3}'`
50 <p>Similar code could be used to extract USB device module
54 if [ -d /sys/bus/usb/devices/ ] ; then
55 echo loaded usb modules:
57 cd /sys/bus/usb/devices/
59 if [ -d "$address/driver/module" ] ; then
60 module=`cd $address/driver/module ; pwd -P | xargs basename`
61 if grep -q "^$module " /proc/modules ; then
62 address=$(echo $address |sed s/0000://)
63 id=$(lsusb -s $address | tail -n 1 | awk '{print $6}')
75 <p>This might perhaps be something to include in other tools as