1 Title: Which module is loaded for a given PCI and USB device?
6 <a href="http://packages.qa.debian.org/discover-data">discover-data</a>
7 package in Debian, there is a script to report useful information
8 about the running hardware for use when people report missing
9 information. One part of this script that I find very useful when
10 debugging hardware problems, is the part mapping loaded kernel module
11 to the PCI device it claims. It allow me to quickly see if the kernel
12 module I expect is driving the hardware I am struggling with. To see
13 the output, make sure discover-data is installed and run
14 <tt>/usr/share/bug/discover-data 3>&1</tt>. The relevant output on
15 one of my machines like this:</p>
22 10de:03f0 snd_hda_intel
31 <p>The code in question look like this, slightly modified for
32 readability and to drop the output to file descriptor 3:</p>
35 if [ -d /sys/bus/pci/devices/ ] ; then
36 echo loaded pci modules:
38 cd /sys/bus/pci/devices/
40 if [ -d "$address/driver/module" ] ; then
41 module=`cd $address/driver/module ; pwd -P | xargs basename`
42 if grep -q "^$module " /proc/modules ; then
43 address=$(echo $address |sed s/0000://)
44 id=`lspci -n -s $address | tail -n 1 | awk '{print $3}'`
54 <p>Similar code could be used to extract USB device module
58 if [ -d /sys/bus/usb/devices/ ] ; then
59 echo loaded usb modules:
61 cd /sys/bus/usb/devices/
63 if [ -d "$address/driver/module" ] ; then
64 module=`cd $address/driver/module ; pwd -P | xargs basename`
65 if grep -q "^$module " /proc/modules ; then
66 address=$(echo $address |sed s/0000://)
67 id=$(lsusb -s $address | tail -n 1 | awk '{print $6}')
79 <p>This might perhaps be something to include in other tools as