[SOLVED] How to determine the type of device driver to implement?
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 to determine the type of device driver to implement?
Hi,
I need to know how to determine, which type of device driver we have to implement based on the hardware peripheral we are connecting to Microprocessor/Microcontroller interfaces. Mostly doubt lies how to distinguish between char and block driver based on the hardware peripheral's transmission of data, as network driver is obvious. Can I have examples for char driver and block driver to get basic idea?
What are you hooking up? Or rather how is it communicating? What's the data form like?
For instance, disks are block drivers and that used to be more obvious because they were previously parallel, however SATA is serial, but disks are still block drivers, similarly things like flash are also block drivers, usually.
Hi Veerain, I thought modem should be programmed as network device driver.
Hi rtmistler, Doesn't the transmitted data form decide the type of driver as you said disks with SATA interface is serial still disks are block drivers. If it is serial it should be sent bytewise right?
Then what are rules that frame if the device should be programmed char or block or network?
And Onebuck as far as I read LDD3 reference I could not get that answer.
Hi rtmistler, Doesn't the transmitted data form decide the type of driver as you said disks with SATA interface is serial still disks are block drivers. If it is serial it should be sent bytewise right?
Used to be the form of transmission and hence one would see "serial" and say "gotta be char driver". Now it's more what the hardware transfer mechanisms permit. Which is to say that it doesn't matter if SATA is serial, or the interface to a flash device is serial like I2C or SPI. If the mode of transfer is that you transfer "blocks" of data versus non-fixed frames, then it doesn't matter what form of transmission is being used. These days almost all transfers are in fact serial, with the exceptions of things like DMA or a custom FGPA/ASIC structure where a similar memory transfer mechanism to DMA is being used.
If your data is transferred in a fixed block size, then you're better off using a block driver.
If your data is transferred in variable sizes, then you're better off using a character driver.
You're not going to have a horrendous failure if you make a decision and choose one architecture over another, these driver types are very similar and the main differences are how they interact with the kernel.
If it is too questionable as to whether or not you're always a block transfer mechanism and feel that character qualities can also lie within your transfer mechanism, then stick with a character driver. That's my recommendation because when you choose to be a block driver, if you have exceptions to the norm, they're more awkward in that driver type. Whereas the character driver expects that no two data transfers are the same size.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.