]> pere.pagekite.me Git - homepage.git/blobdiff - blog/archive/2011/01/index.html
Generated.
[homepage.git] / blog / archive / 2011 / 01 / index.html
index 5adfea80e931dec06e53b2fa279b77df2b46184f..d97664cbb66b5fa306afac0be61dfab100bebebb 100644 (file)
@@ -1313,6 +1313,104 @@ Det er eit godt produkt, brukt av mange og godt likt.»</p>
 </div>
  <div class="padding"></div>
 
 </div>
  <div class="padding"></div>
 
+<div class="entry">
+ <div class="title">
+ <a href="http://people.skolelinux.org/pere/blog/Which_module_is_loaded_for_a_given_PCI_and_USB_device_.html">Which module is loaded for a given PCI and USB device?</a>
+ </div>
+ <div class="date">
+  2011-01-23 00:20
+ </div>
+
+ <div class="body">
+  
+<p>In the
+<a href="http://packages.qa.debian.org/discover-data">discover-data</a>
+package in Debian, there is a script to report useful information
+about the running hardware for use when people report missing
+information.  One part of this script that I find very useful when
+debugging hardware problems, is the part mapping loaded kernel module
+to the PCI device it claims.  It allow me to quickly see if the kernel
+module I expect is driving the hardware I am struggling with.  To see
+the output, make sure discover-data is installed and run
+<tt>/usr/share/bug/discover-data 3>&1</tt>.  The relevant output on
+one of my machines like this:</p>
+
+<pre>
+loaded modules:
+10de:03eb i2c_nforce2
+10de:03f1 ohci_hcd
+10de:03f2 ehci_hcd
+10de:03f0 snd_hda_intel
+10de:03ec pata_amd
+10de:03f6 sata_nv
+1022:1103 k8temp
+109e:036e bttv
+109e:0878 snd_bt87x
+11ab:4364 sky2
+</pre>
+
+<p>The code in question look like this, slightly modified for
+readability and to drop the output to file descriptor 3:</p>
+
+<pre>
+if [ -d /sys/bus/pci/devices/ ] ; then
+    echo loaded pci modules:
+    (
+        cd /sys/bus/pci/devices/
+        for address in * ; do
+            if [ -d "$address/driver/module" ] ; then
+                module=`cd $address/driver/module ; pwd -P | xargs basename`
+                if grep -q "^$module " /proc/modules ; then
+                    address=$(echo $address |sed s/0000://)
+                   id=`lspci -n -s $address | tail -n 1 | awk '{print $3}'`
+                    echo "$id $module"
+                fi
+            fi
+        done
+    )
+    echo
+fi
+</pre>
+
+<p>Similar code could be used to extract USB device module
+mappings:</p>
+
+<pre>
+if [ -d /sys/bus/usb/devices/ ] ; then
+    echo loaded usb modules:
+    (
+        cd /sys/bus/usb/devices/
+        for address in * ; do
+            if [ -d "$address/driver/module" ] ; then
+                module=`cd $address/driver/module ; pwd -P | xargs basename`
+                if grep -q "^$module " /proc/modules ; then
+                    address=$(echo $address |sed s/0000://)
+                    id=$(lsusb -s $address | tail -n 1 | awk '{print $6}')
+                    if [ "$id" ] ; then
+                        echo "$id $module"
+                    fi
+                fi
+            fi
+        done
+    )
+    echo
+fi
+</pre>
+
+<p>This might perhaps be something to include in other tools as
+well.</p>
+
+ </div>
+ <div class="tags">
+
+  Tags: <a href="http://people.skolelinux.org/pere/blog/tags/debian">debian</a>, <a href="http://people.skolelinux.org/pere/blog/tags/english">english</a>.
+ </div>
+</div>
+ <div class="padding"></div>
+
  <p style="text-align: right;"><a href="01.rss"><img src="http://people.skolelinux.org/pere/blog/xml.gif" alt="RSS Feed" width="36" height="14"></a></p>
 
 
  <p style="text-align: right;"><a href="01.rss"><img src="http://people.skolelinux.org/pere/blog/xml.gif" alt="RSS Feed" width="36" height="14"></a></p>
 
 
@@ -1325,7 +1423,7 @@ Det er eit godt produkt, brukt av mange og godt likt.»</p>
 <li>2011
 <ul>
 
 <li>2011
 <ul>
 
-<li><a href="http://people.skolelinux.org/pere/blog/archive/2011/01/">January (13)</a></li>
+<li><a href="http://people.skolelinux.org/pere/blog/archive/2011/01/">January (14)</a></li>
 
 </ul></li>
 
 
 </ul></li>
 
@@ -1413,13 +1511,13 @@ Det er eit godt produkt, brukt av mange og godt likt.»</p>
 
  <li><a href="http://people.skolelinux.org/pere/blog/tags/bootsystem">bootsystem (10)</a></li>
 
 
  <li><a href="http://people.skolelinux.org/pere/blog/tags/bootsystem">bootsystem (10)</a></li>
 
- <li><a href="http://people.skolelinux.org/pere/blog/tags/debian">debian (46)</a></li>
+ <li><a href="http://people.skolelinux.org/pere/blog/tags/debian">debian (47)</a></li>
 
  <li><a href="http://people.skolelinux.org/pere/blog/tags/debian edu">debian edu (58)</a></li>
 
  <li><a href="http://people.skolelinux.org/pere/blog/tags/digistan">digistan (7)</a></li>
 
 
  <li><a href="http://people.skolelinux.org/pere/blog/tags/debian edu">debian edu (58)</a></li>
 
  <li><a href="http://people.skolelinux.org/pere/blog/tags/digistan">digistan (7)</a></li>
 
- <li><a href="http://people.skolelinux.org/pere/blog/tags/english">english (84)</a></li>
+ <li><a href="http://people.skolelinux.org/pere/blog/tags/english">english (85)</a></li>
 
  <li><a href="http://people.skolelinux.org/pere/blog/tags/fiksgatami">fiksgatami (1)</a></li>
 
 
  <li><a href="http://people.skolelinux.org/pere/blog/tags/fiksgatami">fiksgatami (1)</a></li>