The Linux kernel Identifies a driver by its <major,monor> number pair .Here is the listing of /dev
The fifth column corresponds to the major number of the devices and the 6th row correponds to the minor number of the device.
The same major number and can assigned to another driver but it will have a different minor number .
There is always a possibility that the major number assigned to a driver already exist and is being by another driver.
To prevent this its always better to dynamically assign the Major nubmer to a driver and let the kernel allocate a Major number which is freely available at the time of driver registration .
This is achieved by using the following call
int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name);
1.The first parameter is the pointer to a variable of data type dev_t , the call fills the variable with the value of the new dynamically assigned major number .
2.The second parameter the starting Minor number to be paired up along with the major number and the 3rd parameter is the total number of minor number required to be assingned starting from the minor nubmer specified in the second argument (second parameter) to the call .
3.Any Device Driver in Linux which is assigned a Major number by the kernel will be listed by the kernel in the file /proc/devices with name of the device and its Major Number .The fourth argument is the name with which the device will be listed in the file /proc/devices .
unregister_chrdev_region(Dev_t Dev,unsigned int count); is used to unregister the registered device .