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