Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-17-2009, 06:48 AM   #1
Registered: Apr 2008
Location: Espaņa
Distribution: Suse
Posts: 220

Rep: Reputation: 32
Doubt with a Linux driver and several devices.....


I have developed a linux driver for our pci card.
Well, driver works fine but now I have a doubt.
Our pci card at the beginig, had one interface of comunication, but now,
this card have two interface of comunication, and I do not know how to handle second device.

I suppose that I need a new device in /dev folder to handle it. First one is "pci_if0" and new one is "pci_if1".

My question is, if a open both device, how driver detect that I try to use "pci_if0" or "pci_f1"??
Can I handle both device with the same linux driver???

Could somebody give a idea??

Thank you very much.
Old 03-17-2009, 08:24 AM   #2
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
Generally the "minor" number of your device inode refer to which instance of device you're using. So you'll use the same driver on different instance of the same device. Thus in the driver, you have to handle multiple device instance, for example, you can have an array of structures which carrying your driver info, instead of just one structure. Each structure for each instance (and each minor number). As you've said, you have as many inode in the the "/dev" directory as needed, each one with its own minor number, the name can be totally different (but it's not a good idea) since the driver doesn't care about the inode name, what is revelent for the driver is the major (what kind of device, so what driver to use), and the minor (what instance of the device you're using).
You can get the minor from the "file*" (and inode*) structure argument of your driver's file operation with the "MINOR" macro.
I hope this help.
Old 03-17-2009, 09:55 AM   #3
Registered: Apr 2008
Location: Espaņa
Distribution: Suse
Posts: 220

Original Poster
Rep: Reputation: 32
Thank you very much.

this is the information that I need it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux device driver project needs more unsupported devices to work on! LXer Syndicated Linux News 0 10-25-2007 10:40 AM
Doubt in char device driver for linux 2.6 tomkaith13 Programming 6 11-27-2006 05:46 AM
Doubt in linux herbertgnanaraja Programming 1 08-30-2006 06:35 AM
No PCMCIA Driver in /proc/devices??? 10xOXR Linux - Laptop and Netbook 1 09-09-2005 03:26 PM
Driver Doubt. bella General 1 05-07-2003 07:58 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration