In this tutorial we will look at the basics of character device drivers. We are going to look at character device drivers first because it is much easier to write a simple character device driver than it is to write a simple block device driver, although, by the time you get on to writing a serious device driver for a new piece of hardware it doesn't matter which type you are working on, they are equally complex. As the operation of a serious device driver is very hardware specific it would not make a particularly good example to work through. To start with we shall be more concerned with the principles involved rather than hardware specifics.
A device driver is just a collection of routines with various specific tasks to perform. Each device driver has essentially the same set of routines and so some mechanism is required to prevent name clashes between drivers. A simple mechanism is to make all the names unique. This is done by choosing a simple unique prefix for each device driver which will be added to the start of all the function names in the driver. This means that even though most device drivers will provide an open() routine, for instance, the prefix for each driver will make all the open() routine names unique within the kernel.