Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-12-2014, 05:37 PM   #1
Registered: Jun 2013
Location: California
Distribution: Ubuntu, Fedora
Posts: 75

Rep: Reputation: Disabled
Two different types of device drivers


I feel that there are two different types of device drivers.

Type 1: the device driver provides userspace API such as .read, .write and .ioctl. The driver is assigned a major/minor number and userspace program may access physical devices by use the API it provides.

Type 2: the device driver doesn't not provide user space API (no read, write or .ioctl), and the driver is used by another driver in the kernel.

So how do I categorize these two types of drivers? What are the correct technical terms for them?

Old 06-13-2014, 07:14 AM   #2
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,647
Blog Entries: 13

Rep: Reputation: 4726Reputation: 4726Reputation: 4726Reputation: 4726Reputation: 4726Reputation: 4726Reputation: 4726Reputation: 4726Reputation: 4726Reputation: 4726Reputation: 4726
Depending on how you perceive things, there are a few different type of device drivers. I've always thought there were: character, block, and network device driver categories; however it's been a while and mainly I dealt with character drivers, which are of the read/write/ioctl variety.

Here are some references:
Old 06-13-2014, 11:56 AM   #3
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Those layered drivers... such as the device drivers handled by the SCSI module (each SCSI device has its own driver, and USB/ATAPI drivers, SATA drivers...).

The drivers are device drivers, which interface to the device by passing command packets to the middle layer driver (the controller driver) that hand off those packets to the physical device over the peripheral bus (USB/SCSI/SATA/ATAPI or PATA and others).

As I understand it, the controller drivers still provide the read/write/... device operations as that is how the procfs and sysfs provides access to controller configuration/statistics (/proc/bus, and /sys/bus).

Also note - the controller drivers provide global functions that implement the interface to the specific controller for the layered drivers (for USB, they are "usb_<function name>") and it is up to the device driver to register with the controller driver when loaded, and unregister when being removed. This maintains a reference count for the controller driver that prevents it from being removed out from under the device drivers that are still available/active (that would cause a crash - usually due to an invalid address being used for a function call).

The "block" or "character" devices is an external designation based on how it works (it is more historical than required - but it allows devices that are primarily block oriented to be categorized that way from those that are stream oriented (everything else). It does allow for some optimization of buffer handling for block devices - but in operation there isn't that much of a difference.

Historical note: Originally drivers were put into one or two tables - The order of entry in the table defined the major number. Block drivers went into the block list, stream drivers went into the character table. But then operating modes of disk drivers allowed raw access (hence the addition of the block devices to the character table). This was partially done to allow ioctl functions (which were always unique to the driver, but not defined for the block list - at least, I don't remember an entry for it) to do really oddball things (like rewinding a disk???). Adding block devices to the character table allowed for access to functions like low level formatting disks, bad block management... Things that made sense to have access to, but outside the functions read/writing blocks of data.

PS. There is also a third major driver - one that interfaces not with a device (or controller) but interfaces with the system (procfs, devfs...) These drivers are usually built into the kernel rather than being modules that can be loaded/removed. And then there are filesystems... But now it starts getting vague as to the definition of "driver", as modules can be drivers... except when they are not (is a security module a "driver"???)

Last edited by jpollard; 06-13-2014 at 12:23 PM. Reason: someday I will learn to type...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
linux device drivers : how can i unregister a character device ? zampa Linux - General 5 06-21-2012 05:34 AM
[SOLVED] URGENT : How to handle one device through two separted device drivers Khadidja Linux - Kernel 2 02-16-2011 02:33 AM
[SOLVED] Conflicting type declarations between sys/types.h and linux/types.h Da Shi Cao Programming 3 09-13-2010 11:55 PM
sys/types.h & linux/types.h conflict while compiling johnnyhal Linux - Software 1 12-28-2008 06:39 PM
conflicting redeclaration of sys/types.h and linux/types.h schmil Programming 6 12-11-2008 02:02 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:10 AM.

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