Is Kernel module is the same as a device driver?


 
Thread Tools Search this Thread
Operating Systems Linux Fedora Is Kernel module is the same as a device driver?
# 8  
Old 05-04-2011
Perderabo,

I've been spending considerable amount of time by trying to follow your command line, but apparently, at this point, it's too much for me. I've been learning about "awk" and "sort", however... could you please elaborate in few sentences about what your specific "awk" does and how did you know where to look?
# 9  
Old 05-04-2011
I've known for a long time that device files are in /dev. However, I forget how I came to know that. So remember this thread!! Then when someone asks you 30 years from now how you knew that device files are in /dev you can refer him to this forum. We always appreciate referrals from our members.

So I list the files in /dev. Then, with awk I select only those with field 5 equal to "1," which is the major number. And I sort the output by 1st character (which is driver type -- actually file type but same difference) and field 6 (which is the minor number).
This User Gave Thanks to Perderabo For This Post:
# 10  
Old 05-04-2011
Perderabo,

First, thanks man! Second, I do like your sense of humor. Third, I know about /dev, what I've ben asking, how to figure out that I need this or that major number. Is it something that you simply know/remember as a result of long experience, or there's some place where it all is mapped out?

Again, thanks for explaining "awk" statement. It appears like a very flexible tool, I'm going to spend some time on it.
# 11  
Old 05-04-2011
Well I didn't really "need" any particular major number. Somehow "1" just came quickly to mind as something to use as an example. Then I was just showing the link betwen the driver and the device file (which is major number). As I said, the drivers are listed in that /usr/include/linux/major.h file so I guess you could say that "maps it out". I really don't know what info you're looking for... Smilie
# 12  
Old 05-04-2011
I don't think looking at the major numbers in a microscope is going to tell you what you want. The whole point of device files is to not have to care about that; they don't have a whole lot to do with what specific driver is being used. They'll tell you broad things about what class of driver, perhaps.

Quote:
Originally Posted by Corona688
The kernel knows what a major+minor number means, but this often just deals with generic input layers like "SCSI disk" -- which these days can mean anything from USB to SATA to PATA, not just actual SCSI. That Linux is now able to treat nearly all disks so identically is mostly a good thing -- device names don't mysteriously change from hda to sda anymore -- but also means it doesn't tell you much about which driver's used.

Try lspci -k, that'll tell you what PCI/AGP/PCIE devices are being claimed by what modules. You can also explore the virtual /sys/ directories to find out more about the devices within.
# 13  
Old 05-05-2011
In a course of reading, watching DVDs and browsing it, I'm gradually start getting it. You see I'm used to windows ways... However how do you guys troubleshoot devices if there's no clear indication which driver does what? Let say I have some webcam or sound card, and how I can get the indication that driver for it is installed, and works properly? Or in a case it is installed but conflict with other driver over resources, how it can be determined? All with "lspci" ? You see in windows I have a chain to follow. I can't see this chain as clearly here so far. I realize that I'm newbie, but in windows information is readily available, and here I have to dig it out every piece by piece.
# 14  
Old 05-05-2011
Quote:
Originally Posted by newlinuxuser1
However how do you guys troubleshoot devices if there's no clear indication which driver does what?
It's not like windows where you install one specific driver and have to use that hardware for life or it'll try to reconfigure itself. Linux decides which drivers to load at runtime with little to no fuss. Build every possible driver into your kernel and nearly all the time it'll choose the correct drivers and ignore the rest. I've dubbed one linux installation onto another totally different computer and gotten it to boot with no change.

There's plenty of indication which driver does what if you've ever compiled your own kernel, most selectable driver options will tell you what hardware they apply to(usually the chipset, not a brand-name). And you can tell which ones got loaded on boot via lsmod. Drivers are also frequently a lot more generic than Windows ones; sometimes one driver can handle tons of devices. Like usb-storage(flash drives), linux-uvc(webcams, cameras), ahci(SATA disk controllers), and so forth.

If anything went wrong you can check the driver messages with dmesg. As long as your system has a working console and working disk drivers you can debug from there.

This works because plug-and-play devices include device ID's to tell you which driver to use. With rare exceptions* you can't use the wrong driver, Linux drivers know what ID's they ought to talk to. The kernel can choose intelligently which driver to load, on-the-fly. Sometimes when a new device comes out, all they need to update is the ID's for the old driver to successfully use new hardware.

These ID's are what things like lspci and lsusb look at to tell you what devices you've got plugged in. They just take the ID's and consult a giant text list to tell you. This also means you don't actually have to have the driver for lspci to tell you what they are, quite unlike Windows -- which is just plain lost without an applicable driver available and no direct way to get the PCI id to even look it up.
Quote:
You see in windows I have a chain to follow.
Yes, 1) download from manufacturer, 2) follow directions, 3) as a last resort Windows Update, or else 4) complain. None of these give you much real information.

* The Realtek 8139 is an annoying exception. There's two incompatible variants with the same PCI ID. One's handled by the 8139cp module, the other by the 8139too module. When it doesn't work it tells you in dmesg to load the other driver. Another exception is video hardware acceleration, very complicated and proprietary, but since that's not needed to boot, that at least can be troubleshooted. Another is sound, because there's 1238957102351 different sound devices with the same PCI ID of "intel/amd/nvidia high-definition audio". The alsa-config utility can tell them apart fortunately.

Last edited by Corona688; 05-05-2011 at 05:10 PM..
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

2. Linux

Linux Device Driver: avoid mem copy from/to user/kernel space

I recently started working with Linux and wrote my first device driver for a hardware chip controlled by a host CPU running Linux 2.6.x kernel. 1. The user space process makes an IOCTL call with pointer to a user memory buffer. 2. The kernel device driver in the big switch-case of IOCTL,... (1 Reply)
Discussion started by: agaurav
1 Replies

3. Solaris

SUNWglmr -- rasctrl environment monitoring driver for i2c or SCSI device driver ?

I've been researching minimizeing Solaris 8 and found that on the web page http://www.sun.com/bigadmin/content/packagelist/s8u7PkgList/p2.html the package SUNWglmr is listed as "rasctrl environment monitoring driver for i2c, (Root) (32-bit)" while in the document "Solaris 8 minimize-updt1.pdf"... (1 Reply)
Discussion started by: roygoodwin
1 Replies

4. UNIX for Advanced & Expert Users

Kernel and Device Driver Programming

I am looking for a guide on how to program for either the Linux or FreeBSD (includes 4.4BSD, NetBSD or OpenBSD) kernel. I would prefer to learn how to write device drivers, but anything would help. If you know, please email me at *removed* or leave a post here Regards, Farhan (0 Replies)
Discussion started by: Farhan
0 Replies
Login or Register to Ask a Question