title: How to know if there is a (compiled in/kernel module) device driver controlling a device on a running linux?
body: <p>How can I know if a device is supported on a running Linux and if so, which device driver controls it?
  For instance, <code>lspci</code> on a server (PowerEdge 2900) gives:</p>
  
  <pre class="lang-none prettyprint-override"><code>00:00.0 Host bridge: Intel Corporation 5000X Chipset Memory Controller Hub (rev 12)
  00:02.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x4 Port 2 (rev 12)
  00:03.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x4 Port 3 (rev 12)
  00:04.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x4 Port 4 (rev 12)
  00:05.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x4 Port 5 (rev 12)
  00:06.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 6-7 (rev 12)
  00:07.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x4 Port 7 (rev 12)
  00:08.0 System peripheral: Intel Corporation 5000 Series Chipset DMA Engine (rev 12)
  00:10.0 Host bridge: Intel Corporation 5000 Series Chipset FSB Registers (rev 12)
  00:10.1 Host bridge: Intel Corporation 5000 Series Chipset FSB Registers (rev 12)
  00:10.2 Host bridge: Intel Corporation 5000 Series Chipset FSB Registers (rev 12)
  00:11.0 Host bridge: Intel Corporation 5000 Series Chipset Reserved Registers (rev 12)
  00:13.0 Host bridge: Intel Corporation 5000 Series Chipset Reserved Registers (rev 12)
  00:15.0 Host bridge: Intel Corporation 5000 Series Chipset FBD Registers (rev 12)
  00:16.0 Host bridge: Intel Corporation 5000 Series Chipset FBD Registers (rev 12)
  00:1c.0 PCI bridge: Intel Corporation 631xESB/632xESB/3100 Chipset PCI Express Root Port 1 (rev 09)
  00:1d.0 USB Controller: Intel Corporation 631xESB/632xESB/3100 Chipset UHCI USB Controller #1 (rev 09)
  00:1d.1 USB Controller: Intel Corporation 631xESB/632xESB/3100 Chipset UHCI USB Controller #2 (rev 09)
  00:1d.2 USB Controller: Intel Corporation 631xESB/632xESB/3100 Chipset UHCI USB Controller #3 (rev 09)
  00:1d.3 USB Controller: Intel Corporation 631xESB/632xESB/3100 Chipset UHCI USB Controller #4 (rev 09)
  00:1d.7 USB Controller: Intel Corporation 631xESB/632xESB/3100 Chipset EHCI USB2 Controller (rev 09)
  00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev d9)
  00:1f.0 ISA bridge: Intel Corporation 631xESB/632xESB/3100 Chipset LPC Interface Controller (rev 09)
  00:1f.1 IDE interface: Intel Corporation 631xESB/632xESB IDE Controller (rev 09)
  00:1f.2 IDE interface: Intel Corporation 631xESB/632xESB/3100 Chipset SATA IDE Controller (rev 09)
  01:00.0 PCI bridge: Intel Corporation 80333 Segment-A PCI Express-to-PCI Express Bridge
  01:00.2 PCI bridge: Intel Corporation 80333 Segment-B PCI Express-to-PCI Express Bridge
  02:0e.0 RAID bus controller: Dell PowerEdge Expandable RAID controller 5
  04:00.0 PCI bridge: Broadcom EPB PCI-Express to PCI-X Bridge (rev c3)
  05:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet (rev 12)
  06:00.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express Upstream Port (rev 01)
  06:00.3 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express to PCI-X Bridge (rev 01)
  07:00.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express Downstream Port E1 (rev 01)
  07:01.0 PCI bridge: Intel Corporation 6311ESB/6321ESB PCI Express Downstream Port E2 (rev 01)
  08:00.0 PCI bridge: Broadcom EPB PCI-Express to PCI-X Bridge (rev c3)
  09:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet (rev 12)
  0b:02.0 Multimedia audio controller: Creative Labs SB Audigy (rev 03)
  0b:02.1 Input device controller: Creative Labs SB Audigy Game Port (rev 03)
  0b:02.2 FireWire (IEEE 1394): Creative Labs SB Audigy FireWire Port
  10:0d.0 VGA compatible controller: ATI Technologies Inc ES1000 (rev 02)
  </code></pre>
  
  <p>How can I find:</p>
  
  <ol>
  <li>which device driver (kernel module) controls each device?</li>
  <li>which device is controlled by a device driver compiled <em>in</em> the kernel (and not as a module)</li>
  <li>which device doesn't have a device driver (compiled in or as a module)?</li>
  </ol>
  
  <p>This script (adapted from another in "Linux Kernel in a Nutshell") partially resolves #1:</p>
  
  <pre class="lang-bash prettyprint-override"><code>#!/bin/bash
  for i in $(find /sys/ -name modalias); do
      echo "----------------------------------"
      modalias=$(cat $i)
      echo "$(dirname $i) --&gt;  $modalias" 
      /sbin/modprobe --config /dev/null --show-depends $(cat $i) 2&gt;&amp;1
  done
  </code></pre>
  
  <p>But there are some problems with it:</p>
  
  <ol>
  <li><p>I don't know of an <em>automated way</em> to convert
  <code>/sys/devices/pci0000:00/0000:00:1e.0/0000:10:0d.0 --&gt;  pci:v00001002d0000515Esv00001028sd000001B1bc03sc00i00</code>
  to
  <code>10:0d.0 VGA compatible controller: ATI Technologies Inc ES1000 (rev 02)</code></p></li>
  <li><p>In some cases the devices are internal to the MB and I don't even know a way to find the real name of the device. For example:</p></li>
  </ol>
  
  <pre class="lang-none prettyprint-override"><code>/sys/devices/platform/dcdbas --&gt;  platform:dcdbas
  /sys/devices/platform/iTCO_wdt --&gt;  platform:iTCO_wdt
  /sys/devices/LNXSYSTM:00 --&gt;  acpi:LNXSYSTM:
  /sys/devices/LNXSYSTM:00/device:00/PNP0C33:00 --&gt;  acpi:PNP0C33:PNP0C01:
  /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00 --&gt;  acpi:PNP0A08:PNP0A03:
  /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:0d/PNP0200:00 --&gt;  acpi:PNP0200:
  </code></pre>
  
  <p>and many others.</p>
  
  <ol start="3">
  <li>When the device driver is <em>compiled in</em> (or doesn't exist) the response is <code>FATAL: Module _XXXX_ not found.</code> Indicating there is no module for the device.</li>
  </ol>
  
  <p>In some cases the driver is compiled in (e.g.)</p>
  
  <pre><code>/sys/devices/platform/serial8250 --&gt;  platform:serial8250
  FATAL: Module platform:serial8250 not found.
  
  /sys/devices/platform/i8042 --&gt;  platform:i8042
  FATAL: Module platform:i8042 not found.
  </code></pre>
  
  <p>In other cases, the driver just doesn't exist. But I don't know a way to tell the difference.</p>
  
  <p>Does anyone know?</p>