Linux 内核变更导致驱动经常出现的错误记录
1: error: CFLAGS was changed in xxx. Fix it to use ccflags-y。
解决方法: export KBUILD_NOPEDANTIC=1
解决方法: 修改Makefile中的 CFLAGS 为 EXTRA_CFLAGS 或 ccflags-y
2: linux/config.h no found file or folder
解决方法: #include 头文件貌似在2.6.19的内核版本后就没有了, 有此错误的话, 则删除此文件.
3: error: unknown field ‘ioctl’ specified in initializer
解决方法: 所有file_operations结构体中的ioctl函数指针。改为unlocked_ioctl。
4: error: implicit declaration of function ‘init_MUTEX’
解决方法: 2.6.25以后就已经不再使用这个宏了。可以自己手动添加此宏.
#define init_MUTEX(sem) sema_init(sem, 1)
#define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
5: error: ‘TASK_INTERRUPTIBLE’ undeclared
解决方法: 添加 #include 6: error: current->uid
解决方法: 变更为 current->cred->uid.val;
typedef struct {
uid_t val;
} kuid_t;
kuid_t uid;
struct cred {
.......................
kuid_t uid; /* real UID of the task */
kgid_t gid; /* real GID of the task */
kuid_t suid; /* saved UID of the task */
kgid_t sgid; /* saved GID of the task */
kuid_t euid; /* effective UID of the task */
kgid_t egid; /* effective GID of the task */
kuid_t fsuid; /* UID for VFS ops */
kgid_t fsgid; /* GID for VFS ops */
.......................
};
struct task_struct {
...........................
...........................
/* process credentials */
const struct cred __rcu *real_cred; /* objective and real subjective task
* credentials (COW) */
const struct cred __rcu *cred; /* effective (overridable) subjective task
* credentials (COW) */
...........................
.................
};
7: error: 'create_proc_read_entry’or’create_proc_entry’ [-Werror=implicit-function-declaration]
解决方法: 此函数在新内核中已经被 proc_create 或者 proc_create_data 取代. 函数在头文件 #include 中.
8: error: #include 没有文件或目录
解决方法: 删除此行.
9: error: implicit declaration of function ‘usb_buffer_free’
解决方法: 用usb_free_coherent()替代,
说明:
USB: rename usb_buffer_alloc() and usb_buffer_free()
For more clearance what the functions actually do,
usb_buffer_alloc() is renamed to usb_alloc_coherent()
usb_buffer_free() is renamed to usb_free_coherent()
10: error: implicit declaration of funct