ioctl在2.6以后的内核版本被修改成了unlocked_ioctl,
它们两个有什么区别,我也不知道。
unlocked_ioctl出了减少了一个inode参数以外,是完全兼容ioctl的。
只是在注册回调函数时要注意一下
int (*ioctl)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned longarg)
int (*unlocked_ioctl) (struct usb_interface *intf, unsigned int code, void *buf);
如果需要考虑兼容不同内核的话,可以用宏定义兼容。参考如下代码:
struct file_operations fops =
{
.poll = pollFunc,
.open = openFunc,
.release = closeFunc,
#if defined(HAVE_UNLOCKED_IOCTL)
.unlocked_ioctl = unlocked_ioctlFunc,
#else
.ioctl = ioctlFunc,
#endif
};
再用ioctlFunc去调用unlocked_ioctlFun函数。