LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 08-05-2015, 11:15 AM   #1
ayyasprings
Member
 
Registered: Aug 2014
Posts: 118

Rep: Reputation: Disabled
How USB device driver invokes char/block/network layer in kernel?


Hi,

How does the USB device driver identifies which layer ie) char or net or block or tty layer to invoke and pass the information got from USB core? does it uses the device class id or interface class id or which of the other information to identify that the current device belongs to char or block or network type?

Likewise how does PCI device driver identifies the same kind of information as above if it uses char/block/network layer?

Please help!
 
Old 08-05-2015, 09:41 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,805

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Well, it is the device driver itself that determines how a device is interfaced, and so characterises whether the device is a character, block, or network device, and it is the device chipset (vendor ID, Product ID) that is enumerated in the first place that enables the kernel to know which driver to use.

This reference is well worth the read and will answer your questions

http://www.makelinux.net/ldd3/
 
Old 08-06-2015, 11:29 AM   #3
ayyasprings
Member
 
Registered: Aug 2014
Posts: 118

Original Poster
Rep: Reputation: Disabled
Hi ferrari,

Still my doubt is Vendor ID / Product ID can be issued newly for any new products that come into market. If I am right how the kernel is kept informed about the type of the new product whether it is char/block/network type?
Is there any logic in issuing that IDs to the new product so that the kernel interprets based on that logic to identify the type of driver to invoke?

Also do the PCI drivers also identify the driver type whether it is char/block/network using the Vendor ID / Product ID?

And another doubt is when will the driver register/unregister function specific for char/block/network drivers used if there is separate register/unregister functions available for USB,PCI,Bluetooth,tty interfaces?
Do the char/block/network driver register/unregister functions are invoked subsequently by USB/PCI/tty driver registerunregister functions internally, for example when an USB with char device type is used, will the USB register/unregister function invokes char driver register /unregister function?

And I read the book Linux Device Drivers 3rd edition you have mentioned in the previous post. It is missing the answers for my above questions.

Please reply and help!!
 
Old 08-06-2015, 04:16 PM   #4
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,805

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Quote:
Hi ferrari,

Still my doubt is Vendor ID / Product ID can be issued newly for any new products that come into market. If I am right how the kernel is kept informed about the type of the new product whether it is char/block/network type?

Is there any logic in issuing that IDs to the new product so that the kernel interprets based on that logic to identify the type of driver to invoke?

It is the kernel drivers that must be regularly updated to cope with any new chipsets reflecting hardware that they support, and it is the driver that determines how a particular device is handled.

More reading for you
http://www.linuxtopia.org/online_boo...n/ch08s02.html
http://files.kroah.com/lkn/

Quote:
Also do the PCI drivers also identify the driver type whether it is char/block/network using the Vendor ID / Product ID?
Again, it is the driver that provides that abstraction (ie char/block/network etc device). The driver is written to support the hardware, so this influences how the device will be treated in the first place.
 
Old 08-06-2015, 04:28 PM   #5
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,805

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
You're probably better asking some of these questions in the kernel forum, especially as you appear to be delving into the 'nitty-gritty' of how it all works. (I can really only provide a a working overview.)

http://www.linuxquestions.org/questi...nux-kernel-70/

There will be other kernel developer mailing lists and forums that can probably better answer the complexities of kernel drivers and how hardware is handled and interfaced.
 
Old 08-08-2015, 03:26 AM   #6
ayyasprings
Member
 
Registered: Aug 2014
Posts: 118

Original Poster
Rep: Reputation: Disabled
Hi ferrari,

By reading the following link I understood how the kernel invokes the appropriate driver.

http://www.linuxtopia.org/online_boo...n/ch08s02.html

But I dont know while writing USB/PCI device driver where do we pass the information of characteristics of the device whether the device is char or block or network as you have said "it is the device driver itself that determines how a device is interfaced, and so characterises whether the device is a character, block, or network device"?

Please reply to this question as this is the doubt I have asked in the starting of this thread!!
 
Old 08-08-2015, 05:55 AM   #7
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,805

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Quote:
But I dont know while writing USB/PCI device driver where do we pass the information of characteristics of the device whether the device is char or block or network as you have said "it is the device driver itself that determines how a device is interfaced, and so characterises whether the device is a character, block, or network device"?

Please reply to this question as this is the doubt I have asked in the starting of this thread!!
There is no need to use examination marks. People will reply if they understand what you're asking and can help. I'm at the limits of my knowledge with this, hence I'm encouraging you to seek help outside these forums as well. I'm not sure that I can answer your question accurately, or with the depth that you seem to require. I'm not a developer or programmer.

Anyway, from my (limited) understanding a suitable char device node is created (with unique major and minor device numbers) in user space. When a driver is loaded, it registers particular device numbers, and they are used by the kernel to link the driver with a particular device file.

Hopefully these examples will be of help you to gain a better understanding of how it all fits together

http://www.crashcourse.ca/introducti...-device-driver
https://appusajeev.wordpress.com/201...device-driver/
http://www.freesoftwaremagazine.com/.../drivers_linux

Last edited by ferrari; 08-08-2015 at 05:56 AM.
 
  


Reply



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
How toAccess request queue of block device driver (e.g. sda) in my own kernel module nnilesh Linux - Kernel 0 04-03-2012 05:25 AM
Linux Driver - how to read/write a block or character device in kernel space (procfs) stybi Linux - Kernel 1 01-27-2011 06:26 AM
Mtd driver as block device and char device Linux_Kid_ Linux - Kernel 1 12-27-2009 12:17 PM
help for char device driver kirany Linux - Software 1 01-11-2009 05:12 PM
Problem in compiling a char device driver formerly for kernel 2.4 on kernel 2.6 payretep Linux - Newbie 6 09-24-2007 05:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 09:20 AM.

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