#include”header24.h”
int i,retvl;
module_param(i,int,S_IRUGO);
int init_function(void)
{
retvl=register_chrdev(0,”my_reg”,&fops);
if(retvl<0)
printk(KERN_ERR “error\n”);
printk(KERN_INFO “retvl=%d\n”,retvl);
printk(KERN_INFO “HELLO WORLD\n”);
printk(KERN_INFO “process name=%s \t process id=%d”,current->comm,current->pid);
printk(KERN_INFO “i=%d\n”,i);
return 0;
}
void exit_function(void)
{
unregister_chrdev(retvl,”my_reg”);
printk(KERN_INFO “BYE\n”);
}
Blog the errors also……..
i thought we should include 2.4 level headers
int register_chrdev (unsigned int major,const char *name,const struct file_operations *fops);
the return value is saved in retvl it has to be UNSIGNED INT retvl instead of int.
Since you are passing the retvl as the first argument in unregister_chrdev, WHICH IS UNSIGNED again.
int unregister_chrdev(unsigned int major, const char *name);
Plus you can add the following lines to check the unregister_chrdev .
ret = unregister_chrdev(retvl, DEVICE_NAME);
if (ret < 0) printk("Error in unregister_chrdev: %d\n", ret);
This is help out in atleast understanding the problem encountered during unregister_chrdev the device.