Unregistering a character Device driver from /proc/devices
Hi all, i'm reading linux device drivers,
and i'm creating a character driver. I alloc a chrdev region with alloc_chrdev_region(&dev,minor_number,number_of_devs); how can i deallocate it ? I tried with unregister_chrdev_region but it does work only for statically allocated devices. i want to deallocate it so that only a single major number is assigned to my driver and cat /dev/devices | grep $dev_name returns no more than 1 line. |
This is the format for alloc_chrdev_region:
Code:
int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) baseminor is the starting minor number (probably 0). count is the number of potential character devices (minor numbers will be baseminor through count - 1) name is the name of the driver that will appear in /proc/devices (not /dev/devices) NOTE: You should make sure the return value is 0 before moving on in the driver and exit if it isn't. To unregister, use unregister_chrdev_region: Code:
void unregister_chrdev_region(dev_t from, unsigned count) count is the same count from alloc_chrdev_region. NOTE: Regardless of what you specify for count, using: Code:
cat /proc/devices | grep $dev_name |
All times are GMT -5. The time now is 11:41 PM. |