Device driver with multiple devices; reading issues...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I'm writing a PCI driver that should work for a multiple of PCI-cards
in a system, for each card that is found, a character device file is
generated. This all works now and I'm at the point to write the read/
write functions.

I have a question about this situation:

Suppose I have four cards in my system and they're all recognized
etc., i.e. there is a character device file for each of the card
called /dev/pcitest-0..3.

Let's say I would like to read 5 bytes from card 2 (/dev/pcitest-1) as a test:

$ dd if=/dev/pcitest-1 bs=5 count=1

The functions open, read and close of my pcitest driver are called in
this order and all works fine but it makes no difference for all the
/dev/pcitest-... files as there is only *one* open/ read/ close
function...Hmmm?

My point is, how can I 'see' in the read function which physical
device is addressed? As far as I know the registration of the
character devices in the kernel is not linked to specific devices but
to the _module_ itself. So the module gets four character device files
to which it 'listens'.

Can someone fill me in here?

Thanks in advance,

Kris

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux