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 <linux/config.h>
头文件貌似在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以后就已经不再使用这个宏了。可以自己手动添加此宏.
- 1
- 2
- 3
5: error: ‘TASK_INTERRUPTIBLE’ undeclared
解决方法: 添加 #include <linux/sched.h>
6: error: current->uid
解决方法: 变更为 current->cred->uid.val;
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
7: error: ‘create_proc_read_entry’or’create_proc_entry’ [-Werror=implicit-function-declaration]
解决方法: 此函数在新内核中已经被 proc_create
或者 proc_create_data
取代。函数在头文件 #include <linux/proc_fs.h>
中。
8: error: #include <asm/semaphore.h> 没有文件或目录
解决方法: 删除此行.
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 function ‘lock_kernel’
解决方法: 删除或者根据代码进行对应的替换, 在内核锁已经从新版本中移除.
11: error : struct tty_struct has no member named ‘flip’, flip.count错误;
解决方法: 删除 flip, 直接引用count。在<linux/tty.h>
中,struct tty_struct直接包含了 count, flip被删除.
12: error: tty->termios->c_cflag;
解决方法: 将tty->termios->c_cflag; 变更为 tty->termios.c_cflag;
13: error: ‘struct tty_driver’ has no member named ‘devfs_name’
解决方法: 删除此行, devfs_name成员在新内核版本中被删除.
14: error: ‘TTY_DRIVER_NO_DEVFS’ undeclared (first use in this function)
解决方法: 删除, 新版本中此标志被移除
15:fatal error: asm/system.h : No file or directory #include<asm/system.h>:
- 1
- 2
- 3
- 4
- 5
- 6
16、关于linux内核中找不到asm文件夹:
源代码中没有asm这个文件夹,asm是一个符号连接,只有在你的主makefile的ARCH 变量赋值,编译内核的时候根据ARCH 的配置,
临时的生成asm文件夹及其下的文件,然后指向对应的体系结构的文件,如/include/asm-arm/ ,/include/asm-x86/