I want to see all hardware supported by the kernel in use. For example, if I have the 3.8.x.x version of the Linux kernel, how will I know what hardware is supported there. Tools like lspci, lshw, lscpu and dmidecode only check the hardware that is used at the moment and trying to find this using the loaded modules with lsmod is not handy either.

What I want is something that checks all hardware actually supported by the kernel in use without taking into consideration if I am using that hardware or not.

For the moment I thought of stuff like:

Reading the /lib/modules/3.8.0-5-generic/kernel/drivers and parsing every file.

Downloading the git source of the kernel and grepping it for information about this.

3 Answers
3

What I want is something that checks all hardware actually supported
by the kernel in use without taking into consideration if I am using
that hardware or not.

If you have the .config file the kernel was built with, you can download the source and run make menuconfig, which will give you an idea of A) what hardware it is possible to configure a kernel for (but see NOTE), and B) what hardware your kernel is actually configured for.

So to do this:

Download the source. Your distro may have a package, or you can get them from kernel.org; find your version with uname -r.

Find the .config used for your kernel. If you got the source via your distro, it will hopefully be included; you may also be able to find it somewhere in /boot. Even better: often now distro kernels are built with the /proc/config.gz feature. If it exists, copy that out, ungzip it, rename the file .config and copy it into the top level of the kernel source tree.

Run make menuconfig from inside the top level of the source tree. You will need the ncurses development package installed (ncurses-dev or ncurses-devel) and you need to be root.

You can't do anything bad while using menuconfig beyond change the contents of the .config file, which won't matter (just don't confuse yourself with it later).

NOTE: You can't actually see all the possible hardware configurations at the same time, since different options may appear in one place based on what has been selected some other place. Kernel configuration is a bit of a labyrinth. However, you will definitely see everything that is actually selected (M means it is a module, * means it is built in).

I don't believe what you're looking for is possible; assuming a modular kernel, for example, many modules will fail to initialize themselves if they cannot actually find the hardware they support. So they'll quietly abort.

Parsing the kernel sources, automatically, to look for hardware names/versions/model-numbers would be a huge undertaking. Although there are common subsystems (e.g. serial, scsi, usb) the code isn't necessarily uniform. That will become apparent to you pretty quickly.

Then there is the problem of defining "all hardware", there are many widgets that look very different (other make, model) but are (essentially) the same inside, and others that have (almost) the same model number while their innards are totally different. And it has happened to me that completely unknown stuff worked out of the box, or after googling around a bit and adding an USB identifier.
–
vonbrandFeb 10 '13 at 1:49