电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

class_create(),device_create自动创建设备文件结点

class_create(),device_create自动创建设备文件结点_第1页
1/10
class_create(),device_create自动创建设备文件结点_第2页
2/10
class_create(),device_create自动创建设备文件结点_第3页
3/10
class_create(),dev ice_create 自动创建设备文件结点 . 2011-11-24 17:23:13| 分类: Linux知识点 | 标签:自动创建设备文件结点 |字号大中小 订阅 从linux 内核2.6 的某个版本之后,devfs 不复存在,udev 成为devfs 的替代。相比 devfs,udev 有很多优势,在此就不罗嗦了,提醒一点,udev 是应用层的东东,不要试图在内核的配置选项里找到它;加入对 udev 的支持很简单,以作者所写的一个字符设备驱动为例,在驱动初始化的代码里调用 class_create 为该设备创建一个class,再为每个设备调用 class_device_create 创建对应的设备。(不太明白什么是 devfs,udev,对 linux 中的文件系统没有什么概念呢。) 大致用法如下: struct class *myclass = class_create(THIS_MODULE, “my_device_driver”); class_device_create(myclass, NULL, MKDEV(major_num, 0), NULL, “my_device”); 这样的module 被加载时,udev daemon 就会自动在/dev 下创建my_device 设备文件。 class_create() ------------------------------------------------- linux-2.6.22/include/linux/device.h struct class *class_create(struct module *owner, const char *name) class_create - create a struct class structure @owner: pointer to the module that is to "own" this struct class @name: pointer to a string for the name of this class. 在/sys/class/下创建类目录 class_device_create() ------------------------------------------------- linux-2.6.22/include/linux/device.h struct class_device *class_device_create(struct class *cls, struct class_device *parent, dev_t devt, struct device *device, const char *fmt, ...) class_device_create - creates a class device and registers it with sysfs @cls: pointer to the struct class that this device should be registered to. @parent: pointer to the parent struct class_device of this new device, if any. @devt: the dev_t for the char device to be added. @device: a pointer to a struct device that is assiociated with this class device. @fmt: string for the class device's name ...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

class_create(),device_create自动创建设备文件结点

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部