Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If my target has one device connected and many drivers for that device loaded, how can I understand what device is using which driver?

share|improve this question

migrated from stackoverflow.com Jun 28 '12 at 8:37

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 11 down vote accepted

Just use /sys.

Example. I want to find the driver for my Ethernet card:

$ sudo lspci
...
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 01)
$ find /sys | grep drivers.*02:00
/sys/bus/pci/drivers/r8169/0000:02:00.0

That is r8169.

First I need to find coordinates of the device using lspci; then I find driver that is used for the devices with these coordinates.

share|improve this answer
5  
lspci -v does it by itself. –  poige Jul 1 '12 at 4:50

You can use the lsmod command to get the status of loaded modules / devices drivers in the Linux Kernel.

For a specific device, you can use dmesg |grep <device-name> to get the details too.

share|improve this answer
    
Thanks. But if i loaded two drivers for a device with same major no and different minor no ,and if only one driver is being used for the device ,how can I find which driver is used for that device? –  Deepu Jun 27 '12 at 6:34
    
perhaps this SO question can help you further. –  gkris Jun 27 '12 at 6:49

You may probably refer to the chapter "7.2. Determining the Correct Module from Scratch" in the book "Linux Kernel in a Nutshell". It gives a detailed steps on this topic.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.