我正在尝试为RTC (实时时钟)实现一个驱动程序。我在ioctl中使用了kernel 2.6.32函数。效果很好。但是,当我在内核3.13.0中运行相同的驱动程序时,它给出了一个错误‘struct file_operations’ has no member named ‘ioctl’
当我将ioctl更改为unlocked_ioctl和compat_ioctl时,编译并模块化了插入。
但是在用户应用程序中调用ioctl函数,而不是在模块中调用函数。我必须在用户应用程序中使用什么功能来调用compat_ioctl或unlocked_ioctl
发布于 2014-05-17 11:05:32
检查驱动程序中的参数
定义结构文件操作定义,如
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
};定义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){
....................................
...................................
}
}和应用水平
无需进行任何修改,您可以在应用程序级别上遵循ioctl的基本规则。
https://stackoverflow.com/questions/23708661
复制相似问题