Could any body try his guts to tell me the algorithm of character driver and the meaning of each function…………….like init,alloc,add etc. My knowledge base about char driver upto registration, of module in 2.6.x kernel
Could any body try his guts to tell me the algorithm of character driver and the meaning of each function…………….like init,alloc,add etc. My knowledge base about char driver upto registration, of module in 2.6.x kernel
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
Following are the api along with the parameter and what is achieved from it,on executing.
int register_chrdev_region(dev_t first, unsigned int count,char *name);
register_chrdev_region works well if you know ahead of time exactly which device numbers you want. Often, however, you will not know which major numbers your device will use; to move over to the use of dynamicly-allocated device numbers on the fly, use the following:
int alloc_chrdev_region(dev_t *dev, unsigned int firstminor,unsigned int count, char *name);
cdev_alloc:
struct cdev * cdev_alloc (void);
Allocates and returns a cdev structure, or NULL on failure.
cdev_init:
void cdev_init (struct cdev *cdev,const struct file_operations *fops);
Initializes cdev, remembering fops, making it ready to add to the system with cdev_add.
cdev_add
int cdev_add (struct cdev *p,dev_t dev,unsigned count);
cdev_add adds the device represented by p to the system, making it live immediately, and can be used by the user.
cdev_del
void cdev_del ( struct cdev *p);
cdev_del removes p from the system, possibly freeing the structure itself.
Hope it will clear the doubts.