Find /dev entries for any loaded kernel module.

11 07 2011

Hey folks, just got a quick one for you.

Recently, I needed to find out to which /dev entries a particular driver was attached. For this, I did the following.

First, navigate to /sys. This is where kernel information is stored about devices and drivers. Under here, you’ll notice folders like “block” (for storage devices) and “bus” for pluggable items such as USB devices and PCI cards.

We are going to be looking in “bus”, as the device I am looking for is connected via USB. From /sys/bus, navigate to usb/drivers, and you will see a list of all drivers currently attached to devices connected via USB.

From here, I needed the ftdi_sio driver, so I cd’d into the folder, and had a look around. Nothing which makes much sense so far, but bear with me. There will be one or multiple symlinks in this folder, which consists of numbers, hyphens, colons and dots. These link to each device’s sysfs folder. Run the command:
ls [0-9]*/

This will look in any folder which starts with a number (in this case our two device folders). Within these folders should be your information. In my case, there was a folder in each of them called ttyUSB? (where the ? was a number).

Now I knew that I just had to connect my program to /dev/ttyUSB? to communicate with the devices.

If there’s anything anybody doesn’t understand about this, feels that I could explain better, or simply wants to know more about, then feel free to let me know via the comments.

Have a great day!





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: