linux 编译字符设备驱动错误,centos6.0  TQ2440 linux字符驱动编译、加载所遇问题集锦...

1.我在做字符设备驱动程序(此章讲的是按键点亮led),在编译内核模块时,遇到了如下问题:

CC

[M] drivers/char/s3c24xx_leds.o

drivers/char/s3c24xx_leds.c:7:32: error: asm/arch/regs-gpio.h: No

such file or directory

drivers/char/s3c24xx_leds.c:8:26: error: asm/hardware.h: No such

file or directory

drivers/char/s3c24xx_leds.c:19: error: 'S3C2410_GPB5' undeclared

here (not in a function)

drivers/char/s3c24xx_leds.c:20: error: 'S3C2410_GPB6' undeclared

here (not in a function)

drivers/char/s3c24xx_leds.c:21: error: 'S3C2410_GPB7' undeclared

here (not in a function)

drivers/char/s3c24xx_leds.c:22: error: 'S3C2410_GPB8' undeclared

here (not in a function)

解决方法:头文件的路径不对,asm/arch/regs-gpio.h改为mach/regs-gpio

asm/hardware.h改为mach/hardware.h

2.继续编译又遇问题:

/home/pyf/linux/test/botton.c: In function

`tope_buttons_init':

/home/pyf/linux/test/botton.c:170: error: implicit declaration of

function `class_device_create'

/home/pyf/linux/test/botton.c: In function

`tope_buttons_exit':

/home/pyf/linux/test/botton.c:178: error: implicit declaration of

function `class_device_destroy'

方法: 经过查阅资料,发现创建设备节点使用了两个函数 class_create(),class_device_create(),当然在__exit()函数里,要使用class_destory()和class_device_desotry()注销创建的设备节点!

问题来了,编译了之后,发现报错error:

implicit declaration of function

'class_device_create'等几个错误。经过分析,应该是Linux内核版本不同的原因!早期的版本,使用的是上面说的两个函数,但是在2.6.29以后(我用的是2.6.32的),使用的函数则变成了

class_create()和device_create(),并且要在声明中加入#include

,因为定义这些函数是在Linux2.6.32/include/linux/device.h里面!

所以修改class_device_create

为device_create。class_device_destroy改为device_destroy经过这些修改后,驱动编译成功,就能够自动创建设备节点了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值