1.

How Can We Allocate Device Number Dynamically ?

Answer»

alloc_chrdev_region()will dynamically allocate device numbers.

int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, 

unsigned int COUNT, char *name);

Here

  1. dev is an output-only parameter that will, on successful completion, hold the FIRST number in your ALLOCATED range. 
  2. firstminor should be the requested first minor number to use; it is usually 0
  3. count is the total number of contiguous device numbers you are requesting.
  4. name is the name of the device that should be associated with this number range. it will APPEAR in /proc/devices and sysfs.

alloc_chrdev_region()will dynamically allocate device numbers.

int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, 

unsigned int count, char *name);

Here



Discussion

No Comment Found