I am trying to associate a driver to the '/dev/mem' device (the major no. and minor no. of device is 1,1.)
[vishal@vishalsoni ~]$ ll /dev/mem
crw-r----- 1 root kmem 1, 1 May 30 2005 /dev/mem
so that any read/write/mmap happening to this device.. gives control to my driver.
I am able to Successfully register the device ( dmesg tells this) & below is the code for kernel 1.6 driver.
[vishal@vishalsoni ~]$ uname -a
Linux vishalsoni 2.6.9-1.667 #1 Tue Nov 2 14:41:25 EST 2004 i686 i686 i386 GNU/Linux
int LinuxTestMemDevice_init(void)
{
int rv = -1;
int devno = MKDEV(1,1);
struct cdev my_cdev;
printk("Skelton Driver, version %s\n", DRIVER_VERSION);
my_cdev.owner=THIS_MODULE;
my_cdev.ops =&my_fops;
rv = cdev_add(&my_cdev,devno,1);
if(rv) {
printk(" Error in registering the char device\n");
return -1;
}
else {
printk(" :------------- Succesfully registered the device -----------\n");
printk(" : Major no. of device is :: %d\n",MAJOR(devno));
printk(" : Minor no. of device is :: %d\n",MINOR(devno));
}
return 0;
}
Registration is successful.......
Now when i try to do [vishal@vishalsoni ~]$ cat /dev/mem
my implementation of open does not get called.
As a test.. i have written, just one line code.
static int my_open(struct inode *imem, struct file *fmem)
{
printk(" INSIDE my_open ..................\n");
return 1;
}
Where am i going wrong !!!!!! Your inputs would be greatly appreciated
Thank you,
Regards,
Vishal.