linux device driver - How to call compat_ioctl or unlocked_ioctl? -
i'm trying implement driver rtc (real time clock). used ioctl function in kernel 2.6.32. worked fine. when run same driver in kernel 3.13.0, gave error ‘struct file_operations’ has no member named ‘ioctl’
when changed ioctl unlocked_ioctl , compat_ioctl, compiled , moduled inserted.
but calling ioctl in user application not invoking ioctl function in module. function have use in user application invoke compat_ioctl or unlocked_ioctl?
check arguments in driver
define structure file operation definition like
static struct file_operations query_fops = { .owner = this_module, .open = my_open, .release = my_close, #if (linux_version_code < kernel_version(2,6,35)) .ioctl = my_ioctl #else .unlocked_ioctl = my_ioctl #endif }; define ioctl
#if (linux_version_code < kernel_version(2,6,35)) static int my_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg) #else static long my_ioctl(struct file *f, unsigned int cmd, unsigned long arg) #endif { switch(cmd){ .................................... ................................... } } and application level
no need modification can follow basic rule ioctl @ application level.
Comments
Post a Comment