Few things I happen to notice:
- You need to use
unlocked_ioctl
instead ofcompat_ioctl
.compat_ioctl
is to allow 32-bit user space programs to invokeioctl
calls on a 64-bit kernel. The signature of your ioctl handler function is incorrect (for
unlocked_ioctl
). The expected signature is:long (*unlocked_ioctl) (struct file * filep, unsigned int, unsigned long);
I haven't tried really compiling this code, but I think this should work:
static struct file_operations fops = {
.unlocked_ioctl = device_ioctl
};
long device_ioctl(struct file *filep,
unsigned int cmd,
unsigned long arg)
{
int len = 200;
printk (KERN_INFO "In Device_ioctl !!\n");
switch(cmd)
{
case IOCTL_WRITE_REG:
write_ioctl((unsigned long *)arg);
break;
default:
printk (KERN_INFO "default\n");
return -ENOTTY;
}
printk (KERN_INFO "device_ioctl out\n");
return len;
}