linux新内核编写设备驱动出错的地方
0赞
发表于 2014/1/22 9:04:14
阅读(2357)
1.注释掉#include 这个文件。
2.出现错误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);
所以将.ioctl 改为.unlocked_ioctl
3.出错error:implicit declaration of function 'kmalloc'
2.出现错误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);
所以将.ioctl 改为.unlocked_ioctl
3.出错error:implicit declaration of function 'kmalloc'
添加#include
4.error inserting 'globalmem.ko': -1 Device or resource busy
用cat /proc/devices 命令查看发现主设备号已被占用,所以更改驱动程序
#define GLOBALMEM_MAJOR 为新的数就可以了