error: unknownfield ‘ioctl’ specified in initializer

error: unknownfield ‘ioctl’ specified in initializer

异步通知的意思是:一旦设备就绪,则主动通知应用程序,这样应用程序就根本不需要查询设备的状态,

这一点非常类似于硬件上的“中断”的概念,比较准确的称谓是“信号驱动的异步I/O”。信号是在软件层次上对中断机制的一种模拟,在原理上一个进程接收到一个信号与处理器接收到一个中断请求是一样的。

1)在把驱动从2.6.32 移植到2.6.36时 报错


/home/kernel_test/globalfifo/globalfifo.c:240:2:error: unknown field 'ioctl' specified in initializer

才发现2.6.36的file_operations结构发生了重大变化。(但基本的思想还是不变的)

取消了原有的ioctl成员,添加来新的成员

long(*unlocked_ioctl) (struct file *, unsigned int, unsigned long); long(*compat_ioctl) (struct file *, unsigned int, unsigned long);

2)/home/kernel_test/globalfifo/globalfifo.c:245:2:warning: initialization from incompatible pointer type

出现此种warnning 的原因 “不兼容的指针类型初始化”是你定义的函数类型与接口函数的类型不一样如 把 把返回值 long 定义成了 int

其中:

ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); ssize_t(*write) (struct file *, const char __user *, size_t, loff_t *);

少写const 也会引起 warning 因为在这里const所起的作用是避免函数使用指针去改变了传进来的值

237 238 /*文件操作结构体*/ 239 static const struct file_operations globalfifo_fops = { 240 .owner = THIS_MODULE, 241 .read = globalfifo_read, 242 .write = globalfifo_write, 243 //.ioctl = globalfifo_ioctl, 244 .unlocked_ioctl = globalfifo_ioctl, 245 .poll = globalfifo_poll, 246 .fasync = globalfifo_fasync, /*不要完了在这里也要加上 与内核联系的接口*/ 247 .open = globalfifo_open, 248 .release = globalfifo_release, 249 }; 250 251

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值