(一)解析class_device_create函数

 
(二)当我们使用class_create创建一个类之后我们就可以使用class_device_create函数在这个类下面创建一个设备了,class_create创建查看004_linux驱动之_class_create创建一个设备类
 
(三)class_device_create函数原型
struct class_device *class_device_create(struct class *cls,struct class_device *parent,dev_t devt,struct  device *device,const char *fmt, ...)
 
1. 注解:

/ * *

* class_device_create——创建一个类设备并将其注册到sysfs

* @cls:指向这个设备应该注册到的struct类的指针。

* @parent:指向这个新设备的父结构class_device的指针。

* @devt:添加char设备的dev_t。

* @device:指向与这个类设备相关联的struct设备的指针。

* @fmt:类设备名称的字符串

*

这个函数可以被char设备类使用。一个结构体

* class_device将在sysfs中创建,注册到指定的

*类。

*将创建一个“dev”文件,显示设备的dev_t,如果

* dev_t不是0,0。

*如果一个指向父struct class_device的指针被传入,则为new

*创建的struct class_device将是sysfs中该设备的子设备。

返回指向struct class_device的指针

*电话。可以创建任何可能需要的进一步sysfs文件

*使用这个指针。

*

*注意:传递给这个函数的struct类之前必须有

通过调用class_create()创建。

* /

 
使用示例:

 
(三)当我们需要删除设备时候就需要class_device_unregister这个函数

 

005_linux驱动之_class_device_create函数的更多相关文章

  1. module_init宏解析 linux驱动的入口函数module_init的加载和释放

    linux驱动的入口函数module_init的加载和释放 http://blog.csdn.net/zhandoushi1982/article/details/4927579 void free_ ...

  2. platform驱动之probe函数

    驱动注册的probe函数 probe函数在设备驱动注册最后收尾工作,当设备的device 和其对应的driver 在总线上完成配对之后,系统就调用platform设备的probe函数完成驱动注册最后工 ...

  3. linux驱动的入口函数module_init的加载和释放【转】

    本文转载自:http://blog.csdn.net/zhandoushi1982/article/details/4927579 就像你写C程序需要包含C库的头文件那样,Linux内核编程也需要包含 ...

  4. USB 驱动之 usb_register 函数解析

    前段时间在kernel 添加了 USB to LAN 模块 AX88772B 的驱动. 根据相关添加解析一下 usb_register_driver 函数 drivers/net/usb/asix.c ...

  5. 006_linux驱动之_ioremap函数使用

    (一)学习linux驱动之初,对ioremap函数的个人理解 (二)博客:实验探究 ioremap 这篇文章作者通过验证来阐述自己的观点,个人觉得挺好的 (三)函数原型 基本简介 void * __i ...

  6. 003_linux驱动之_file_operations函数

    (一)解析file_operations函数 解析002_linux驱动之_register_chrdev注册字符设备中的问题 (二) 1. file_operations结构原型 2. 使用举例   ...

  7. linux 内核(驱动)常用函数

    2.4.1 内存申请和释放 include/linux/kernel.h里声明了kmalloc()和kfree().用于在内核模式下申请和释放内存.    void *kmalloc(unsigned ...

  8. 010_Linux驱动之_DECLARE_WAIT_QUEUE_HEAD函数

    1. 功能:创建以个等待队列头 2. 函数原型 #define DECLARE_WAIT_QUEUE_HEAD (name)                            /     wait ...

  9. 009_Linux驱动之_request_irq()函数

    1. request_irq()函数原型 int request_irq(unsigned int irq, irq_handler_t handler, unsigned long irqflags ...

随机推荐

  1. Essential C++ Reading Notes

    Chapter1 P6, 1.2 Why //#include<string> we still can use "string user_name"? -->c ...

  2. LC 173. Binary Search Tree Iterator

    题目描述 Implement an iterator over a binary search tree (BST). Your iterator will be initialized with t ...

  3. Linux (x86) Exploit 开发系列教程之七 绕过 ASLR -- 第二部分

    (1)原理: 使用爆破技巧,来绕过共享库地址随机化.爆破:攻击者选择特定的 Libc 基址,并持续攻击程序直到成功.这个技巧是用于绕过 ASLR 的最简单的技巧. (2)漏洞代码 //vuln.c # ...

  4. asp.net core-12.dotnet watch run 和attach到进程调试

    1.打开visual studio code 创建一个项目 打开终端 输出:  dotnet new web --name hellocore 2.用visual studio code打开项目文件夹 ...

  5. 怎样手写实现 new 命令的功能

    实现new命令的功能, 首先需要知道new命令都做了些什么: 第一步: 创建一个空对象, 作为实例对象的容器; 第二步: 将空对象的prototype指向构造函数的prototype; 第三步: 将空 ...

  6. Shell重定向:2>&1

    Shell重定向:2>&1 0 是一个文件描述符,表示标准输入(stdin) 1 是一个文件描述符,表示标准输出(stdout) 2 是一个文件描述符,表示标准错误(stderr) 重定 ...

  7. poj 3253 哈夫曼贪心

    http://poj.org/problem?id=3253 题意: FJ需要修补牧场的围栏,他需要 N 块长度为 Li 的木头(N planks of woods).开始时,FJ只有一块无限长的木板 ...

  8. Visual Studio 最新插件

    Resharper 最新版本下载 https://www.jetbrains.com/resharper/ 破解方法 安装完成后,打开vs  弹出注册窗口选择Activate>License S ...

  9. .NET中AOP实现

    静态织入,如:PostSharp(收费)动态织入1.使用Castle DynamicProxy不太方便的是需要在AOP的方法上加上virual关键字,配置较繁琐https://blog.csdn.ne ...

  10. Python练习_高阶函数_day11

    1,写函数,传入n个数,返回字典{‘max’:最大值,’min’:最小值} 例如:min_max(2,5,7,8,4) 返回:{‘max’:8,’min’:2}(此题用到max(),min()内置函数 ...