Wednesday, May 19, 2010

How will you register the device

Q)How will you register the device?
A)By default the device are registered from the list of devices made in the /dev/ files.
This is done when we are registering the device:-

--------------> register_chrdev(
unsigned int major,const char *name,const struct file_operations *fops).
There are other two methods other than this which are:-
register_chrdev_region();
alloc_chrdev_region(); Out of all this one is preferred.

If major == 0 this functions will dynamically allocate a major and return its number.

If major > 0 this function will attempt to reserve a device with the given major number and will return zero on success and if not it will returns a -ve errno on failure.

This is done when we are removing the device:-
--------------> unregister_chrdev(
unsigned int major,const char *name).









No comments:

Post a Comment