驱动模块编译错误提示--implicit declaration of function ‘kmalloc’

从新编译以前的一个驱动测试模块

以前是在FC9,但是FC14出现如下编译错误,

make: Entering directory `/usr/src/kernels/2.6.35.6-45.fc14.i686'
  CC [M]  /home/ty/development/driver/ch6/globalmem.o
/home/ty/development/driver/ch6/globalmem.c: In function ‘globalmem_read’:
/home/ty/development/driver/ch6/globalmem.c:77:7: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
/home/ty/development/driver/ch6/globalmem.c: In function ‘globalmem_write’:
/home/ty/development/driver/ch6/globalmem.c:100:7: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
/home/ty/development/driver/ch6/globalmem.c: In function ‘globalmem_init’:
/home/ty/development/driver/ch6/globalmem.c:185:3: error: implicit declaration of function ‘kmalloc’
/home/ty/development/driver/ch6/globalmem.c:185:18: warning: assignment makes pointer from integer without a cast
/home/ty/development/driver/ch6/globalmem.c: In function ‘globalmem_exit’:
/home/ty/development/driver/ch6/globalmem.c:202:3: error: implicit declaration of function ‘kfree’
make[1]: *** [/home/ty/development/driver/ch6/globalmem.o] Error 1
make: *** [_module_/home/ty/development/driver/ch6] Error 2
make: Leaving directory `/usr/src/kernels/2.6.35.6-45.fc14.i686'

 

在网上找了一下,是缺少了一个头文件

#include <linux/slab.h>

加上之后就没问题了

驱动源代码

http://blog.csdn.net/tiany524/archive/2010/09/14/5884535.aspx

你可能感兴趣的:(function,Module,测试,Integer,2010)