EmbLogic's Blog

register the driver acording to 2.4 kernal give error in rmmod and all hedar file and decleartion are include in heder24.h

#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”);
}

3 Responses to register the driver acording to 2.4 kernal give error in rmmod and all hedar file and decleartion are include in heder24.h

  1. Blog the errors also……..

  2. i thought we should include 2.4 level headers

  3. kamran says:

    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.

Leave a Reply to kamran Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>