Skip to content
Advertisement

difference between device file and device driver

I am currently reading the Linux Module Programming Guide and I have stumbled onto two terms that have confused a bit – device files and device driver. Upon goggling these terms I have come across the following-

A device driver is a piece of software that operates or controls a particular type of device.

A device file is an interface for a device driver that appears in a file system as if it were an ordinary file. In Unix-like operating systems, these are usually found under the /dev directory and are also called device nodes.

What I would like to know is –

1) Are device files an interface between user space programs and the device driver? 2) Does the program access the driver in the kernel via the appropriate device special file?

eg, when using say spidev char dev file, does that allow my userspace program to interact with spi.c and omap2_mcspi.c etc using simple read, write and ioctl calls?

Advertisement

Answer

One of the primary abstractions in Unix is the file (source):

Programs, services, texts, images, and so forth, are all files. Input and output devices, and generally all devices, are considered to be files, according to the system.

This lets users treat a variety of entities with a uniform set of operations, even through the implementation of those operations may be wildly different.

As you were getting at with your question, device files are the user facing side of the abstraction. This is what the user sees; a file that they can write to, read from, open, close, etc. The device drivers are the implementation of those operations.

So the user will make a call to a file operation such as write, and then the kernel will then use the device driver to carry out the operation.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement