一、分配cdev

  cdev表示字符设备,使用cdev_alloc函数,cdev_alloc函数原型如下;

/**
* cdev_alloc() - allocate a cdev structure
*
* Allocates and returns a cdev structure, or NULL on failure.
*/
struct cdev *cdev_alloc(void)

  得到cdev指针

二、初始化cdev

  使用cdev_init函数,cdev_init的原型如下:

/**
* cdev_init() - initialize a cdev structure
* @cdev: the structure to initialize
* @fops: the file_operations for this device
*
* Initializes @cdev, remembering @fops, making it ready to add to the
* system with cdev_add().
*/
void cdev_init(struct cdev *cdev, const struct file_operations *fops)

  将字符设备和设备的操作集合绑定在一起。

三、注册cdev

  注册cdev用cdev_add函数,原型如下:

/**
* cdev_add() - add a char device to the system
* @p: the cdev structure for the device
* @dev: the first device number for which this device is responsible
* @count: the number of consecutive minor numbers corresponding to this
* device
*
* cdev_add() adds the device represented by @p to the system, making it
* live immediately. A negative error code is returned on failure.
*/
int cdev_add(struct cdev *p, dev_t dev, unsigned count)

四、注销cdev

  用cdev_del函数

linux设备注册的更多相关文章

  1. 驱动开发学习笔记. 0.05 linux 2.6 platform device register 平台设备注册 2/2 共2篇

    驱动开发读书笔记. 0.05 linux 2.6 platform device register 平台设备注册 2/2 共2篇 下面这段摘自 linux源码里面的文档 : 内核版本2.6.22Doc ...

  2. 驱动开发学习笔记. 0.04 linux 2.6 platform device register 平台设备注册 1/2 共2篇

    驱动开发读书笔记. 0.04  linux 2.6 platform device register 平台设备注册  1/2 共2篇下面这段摘自 linux源码里面的文档 : Documentatio ...

  3. 深入理解linux网络技术内幕读书笔记(八)--设备注册与初始化

    Table of Contents 1 设备注册之时 2 设备除名之时 3 分配net_device结构 4 NIC注册和除名架构 4.1 注册 4.2 除名 5 设备初始化 6 设备类型初始化: x ...

  4. linux设备驱动程序--在用户空间注册文件接口

    linux字符设备驱动程序--创建设备节点 基于4.14内核,运行在beagleBone green 在上一讲中,我们写了第一个linux设备驱动程序--hello_world,在驱动程序中,我们什么 ...

  5. Linux设备驱动模型之I2C总线

    一.I2C子系统总体架构 1.三大组成部分 (1)I2C核心(i2c-core):I2C核心提供了I2C总线驱动(适配器)和设备驱动的注册.注销方法,提供了与具体硬件无关的I2C读写函数. (2)I2 ...

  6. linux设备模型_转

    建议原博文查看,效果更佳. 转自:http://www.cnblogs.com/wwang/category/269350.html Linux设备模型 (1) 随着计算机的周边外设越来越丰富,设备管 ...

  7. linux设备驱动归纳总结(十三):1.触摸屏与ADC时钟【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-119723.html linux设备驱动归纳总结(十三):1.触摸屏与ADC时钟 xxxxxxxxxx ...

  8. linux设备驱动归纳总结(十二):简单的数码相框【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-116926.html linux设备驱动归纳总结(十二):简单的数码相框 xxxxxxxxxxxxxx ...

  9. linux设备驱动归纳总结(十一):写个简单的看门狗驱动【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-112879.html linux设备驱动归纳总结(十一):写个简单的看门狗驱动 xxxxxxxxxxx ...

随机推荐

  1. 微信小程序手机号解密失败-43001

    今天是2020年1月16号,从昨天下午开始,一直遇到一个问题: 客户在注册会员的时候的第二步,验证手机号的时候,一直提示验证失败,-43001 直接说原因:用户的session_key过期 期间大部分 ...

  2. eclipse 创建自己的Maven项目(超详细)

    本文章 主要是 讲解 是讲解 eclipse创建项目 --SpiritMark_liu 先配置 Maven 的 settings 地址 (Window -> Perferences–>Ma ...

  3. Java 12 新特性

    Java 12 已如期于 3 月 19 日正式发布,此次更新是 Java 11 这一长期支持版本发布之后的一次常规更新,截至目前,Java 半年为发布周期,并且不会跳票承诺的发布模式,已经成功运行一年 ...

  4. 用Python批量爬取优质ip代理

    前言 有时候爬的次数太多时ip容易被禁,所以需要ip代理的帮助.今天爬的思路是:到云代理获取大量ip代理,逐个检测,将超时不可用的代理排除,留下优质的ip代理. 一.爬虫分析 首先看看今天要爬取的网址 ...

  5. matlab双坐标轴设定

    clc; clear all; close all; x1 = 0:.1:40; y1 = 4 * cos(x1)./(x1 + 2); x2 = 1:.2:20; y2 = x2.^2 ./ x2. ...

  6. 【对线面试官】Java注解

    public void send(String userName) {  try {    // qps 上报    qps(params);    long startTime = System.c ...

  7. 工作中用的sql

    //字段是空字符串或者null select * from blade_process_should_pay_invoice where is_deleted = 0 and process_inst ...

  8. 算法(Java实现)—— 贪心算法

    贪心算法 应用场景-集合覆盖问题 假设在下面需要付费的广播台,以及广播台新型号可以覆盖的地区,如何选择最少的广播台,让所有地区都可以接收到信号 广播台 覆盖地区 k1 北京.上海.天津 k2 广州.北 ...

  9. 内部类和Lambda

    1.1 内部类的基本使用 在一个类中定义一个类.举例:在一个类A的内部定义一个类B,类B就被称为内部类 内部类定义格式 格式&举例: /* 格式:    class 外部类名{   修饰符 c ...

  10. filebeat7.5.2 在 windows server 2008 R2 设置系统服务报错

    今天在windows server 2008 R2 设置filebeat为系统服务报错(在 windows 10 .windows server 2012.windows server 2019下安装 ...