I'm trying to implement a driver for RTC (Real Time Clock). I used ioctl function in kernel 2.6.32. It worked fine. But when I run same driver in kernel 3.13.0, it gave an error ‘struct file_operations’ has no member named ‘ioctl’
when I changed ioctl to unlocked_ioctl and compat_ioctl, compiled and moduled inserted.
But calling ioctl in user application not invoking ioctl function in module. What function I have to use in user application to invoke compat_ioctl or unlocked_ioctl?
Check with 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 like
#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 to do any modification you can follow the basic rule for ioctl at application level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With