class_device_create的问题
来源:互联网 发布:知乎 鲥鱼多少钱 编辑:程序博客网 时间:2024/06/06 06:37
class_device_create的问题
今天在编译一个Linux kernel module 的时候,遇到下面的错误:
error: implicit declaration of function ‘class_device_create’
这个代码在Kernel 2.6.18下面编译的时候没有任何问题。为什么在2.6.34下面会出现这个错误呢?难道class_device_create这个kernel API已经从新版kernel里面移除了?
google了一下,发现确实是已经被移除了,在新版的kernel里面,可以使用device_create来代替,参数完全一致。
在LXR(http://lxr.linux.no)网站上面查找了一番,发现class_device_create在2.6.25里面还有,从2.6.26起就被移除了。
Linux Kernel的Kernel API是经常会变化的。这给需要支持多个版本的Driver带来了不小的麻烦。有没有什么地方可以很方便的知道 Linux Kernel各个版本之间Kernel API的变化?暂时没有找到。一个可行的方法是,遇到问题之后,到LXR里面如搜索一下,LXR可以搜索特定的kernel版本。
class_create
之前写的字符类设备驱动,没有自动创建设备节点,因为只使用了register_chrdev()函数,只是注册了这个设备。然后在系统启动后,就要自己创建设备节点mknod,这样虽然是可行的,但是比较麻烦。于是想在__init函数里面,自动创建设备节点。
经过查阅资料,发现创建设备节点使用了两个函数 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 <linux/device.h> ,因为定义这些函数是在Linux2.6.32/include/linux/device.h里面!
经过这些修改后,驱动编译成功,就能够自动创建设备节点了!
原文地址:http://hi.baidu.com/zengzhaonong/item/8a440e10191838e45f53b185
http://wuyanwxt.blog.sohu.com/232836476.html
- class_device_create的问题
- 调用class_create(),class_device_create()函数编译报错的解决方法
- class_create() class_device_create
- class_device_create class_device_destroy
- class_create & class_device_create
- class_device_create函数转
- linux2.6.32 class_device_create
- linux2.6.32 class_device_create
- 关于class_device_create和class_device_destroy
- class_create和class_device_create
- (一)小记——驱动中使用class_device_create()报错的原因、自动创建设备节点
- implicit declaration of function 'class_device_create'
- implicit declaration of function "class_device_create"
- 驱动中使用class_device_create()…
- class_create(),class_device_create()创建/dev/xxx 名字
- class_create(),class_device_create()创建/dev/xxx 名字
- error: implicit declaration of function ‘class_device_create’
- class_create(),class_device_create()创建/dev/xxx 名字
- 谈谈软件架构和架构师--童亚斋
- 转义字符常量
- 在window下设置环境变量
- hibernate调用存储过程及处理返回集合
- 评分控件 更改背景
- class_device_create的问题
- 汇编 Debug使用
- c3p0详细配置
- ubuntu分辨率设置
- Windows消息大全使用的详细介绍
- 登录失败锁定策略配置登录超时策略禁用root远程登录脚本!
- C# 中的委托和事件
- 将字符赋给整型变量
- 软件建模之UML图形讲解