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 04-13-2015, 07:45 AM   #1
ayyasprings
Member
 
Registered: Aug 2014
Posts: 118

Rep: Reputation: Disabled
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?

Please help!
 
Old 04-13-2015, 08:56 AM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
A modem uses a character device file, it sequencially sends a character(byte) at a time.

A floppy/hard disk is example of block device, sends or receives a block of bytes at a time.
 
Old 04-13-2015, 09:02 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,923
Blog Entries: 44

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
Member response

Hi,

Good references;
Quote:
Linux Device Drivers, Third Edition <- 'LDD3 is current as of the 2.6.10 kernel'. + Good online reference

Linux Device Drivers, 4th Edition - O'Reilly Media <- Published, not free
Hope this helps.
Have fun & enjoy!
 
1 members found this post helpful.
Old 04-13-2015, 12:21 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
Old 04-15-2015, 05:25 AM   #5
ayyasprings
Member
 
Registered: Aug 2014
Posts: 118

Original Poster
Rep: Reputation: Disabled
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.

Please help!
 
Old 04-15-2015, 07:09 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by ayyasprings View Post
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.

Excellent book to consider, looks like you can download the chapters online http://lwn.net/Kernel/LDD3/

Last edited by rtmistler; 04-15-2015 at 07:11 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 to implement asynchronous I/O for a char device driver ? tanniru Linux - Kernel 1 02-03-2009 09:15 AM
How to determine device driver versions in RHEL 4 Update 4? bigd00dy Linux - Hardware 2 02-28-2008 06:46 PM
How to determine device driver versions in RHEL 4 Update 4? bigd00dy Linux - Newbie 1 02-28-2008 05:24 PM
how to implement ACPI in linux device driver soararing Programming 4 11-19-2007 08:20 PM
determine type of device for USB devices lyar1031 Linux - Newbie 2 07-29-2004 08:02 PM

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

All times are GMT -5. The time now is 03:11 PM.

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