Section: Kernel Functions (9)
register_chrdev, unregister_chrdev - register a driver major number
int register_chrdev(unsigned int major, const char*name,
int unregister_chrdev(unsigned int major, const char *name);
function associates a character major number with set of driver entry
points. The file_operations structure contains pointers to functions
that the the driver uses to implement the kernel interface to the
is the character major number assigned to the device driver and to be
mapped to the function table. The
parameter is a short name for the device and is displayed in the
list. It also must exactly match the name passed to
function when releasing the functions.
A device driver module may register as many different major numbers as
it supports, though this is not typically done.
function releases the major number, and is normally called in the
module_cleanup function to remove the driver from the kernel.
returns 0 if
is a number other then 0, otherwise Linux will choose a major number
and return the chosen value.
If there is an error, one of the following codes is returned instead:
The specified number is not valid (> MAX_CHRDEV)
The major number is busy
function will return 0 if successful, or
if the major number is not registered with the matching name.
Stephen Williams (email@example.com