How USB device driver invokes char/block/network layer in kernel?
Linux - Embedded & Single-board computerThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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
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.
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.
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.
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.)
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.
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!!
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.