Another new character device infrastructure
[Posted May 28, 2003 by corbet]
Alexander Viro is definitely back, and he has made good on his promises to
rework the character device infrastructure to pave the way for the
dev_t transition. A set of patches merged into 2.5.70 shows where
things are headed.
Character devices are now represented by their own structure:
struct cdev {
struct kobject kobj;
struct module *owner;
struct file_operations *ops;
struct list_head list;
};
It is expected that a cdev structure will be embedded within
larger, subsystem-specific structures. An infrastructure has been set up
which lets drivers register character devices with a CIDR-like scheme - any
range of device numbers, starting with an arbitrary major and minor number,
can be allocated, with more specific allocations overriding wider ranges.
It is, in other words, the same scheme that was implemented some time ago for
block devices (and which is described in this Driver Porting Series
article).
In this scheme, the classic register_chrdev() function is
unchanged; it allocates a cdev structure and registers it with
minor numbers 0-255. So unmodified char drivers will continue to work -
and will not be presented with larger device numbers than before. It
expected that, over time, drivers will move away from the
register_chrdev() interface and toward working with cdev
structures directly.
We'll put out a detailed description of the new interface (as part of the
Driver Porting series) once it has
had a chance to stabilize a bit.
(
Log in to post comments)