zoukankan      html  css  js  c++  java
  • Linux 内核设备驱动

    设备模型跟踪所有对系统已知的驱动. 这个跟踪的主要原因是使驱动核心能匹配驱动和新 设备. 一旦驱动在系统中是已知的对象, 但是, 许多其他的事情变得有可能. 设备驱动可 输出和任何特定设备无关的信息和配置变量, 例如:

    驱动由下列结构定义:

    struct device_driver { char *name;

    struct bus_type *bus; struct kobject kobj; struct list_head devices;

    int (*probe)(struct device *dev); int (*remove)(struct device *dev);

    void (*shutdown) (struct device *dev);

    };

    再一次, 几个结构成员被忽略( 全部内容见 <linux/device.h> ). 这里, name 是驱动的 名子( 它在 sysfs 中出现 ), bus 是这个驱动使用的总线类型, kobj 是必然的 kobject, devices 是当前绑定到这个驱动的所有设备的列表, probe 是一个函数被调用来查询一个 特定设备的存在(以及这个驱动是否可以使用它), remove 当设备从系统中去除时被调用, shutdown 在关闭时被调用来关闭设备.

    使用 device_driver 结构的函数的形式, 现在应当看来是类似的(因此我们快速涵盖它 们). 注册函数是:

    int driver_register(struct device_driver *drv); void driver_unregister(struct device_driver *drv);

    通常的属性结构在:

    struct driver_attribute { struct attribute attr;

    ssize_t (*show)(struct device_driver *drv, char *buf); ssize_t (*store)(struct device_driver *drv, const char *buf, size_t count);

    };

    DRIVER_ATTR(name, mode, show, store);

    以及属性文件以通常的方法创建:

    int driver_create_file(struct device_driver *drv, struct driver_attribute *attr); void driver_remove_file(struct device_driver *drv, struct driver_attribute *attr);

    bus_type 结构含有一个成员( drv_attrs ) 指向一套缺省属性, 对所有关联到这个总线 的驱动都创建.

  • 相关阅读:
    交换机/路由器上的 S口 F口 E口
    对称加密&非对称加密
    字节流和字符流 in Java
    Python中使用MySQL
    完全二叉树、理想二叉树满二叉树
    优化MySchool数据库设计
    关于SQL储存过程中输出多行数据
    关于本月第一天,本月最后一天的SQL代码
    SQL常见的系统存储过程
    相关子查询【SQL Server】
  • 原文地址:https://www.cnblogs.com/fanweisheng/p/11147967.html
Copyright © 2011-2022 走看看