转自:http://blog.csdn.net/tangkegagalikaiwu/article/details/8444249

This pci_device_id structure needs to be exported to user space to allow the hotplug and module loading systems know what module works with what hardware devices. The macroMODULE_DEVICE_TABLE accomplishes this. An example is:

MODULE_DEVICE_TABLE(pci, i810_ids);

This statement creates a local variable called _ _mod_pci_device_table that points to the list ofstructpci_device_id. Later in the kernel build process, the depmod program searches all modules for the symbol _ _mod_pci_device_table. If that symbol is found, it pulls the data out of the module and adds it to the file/lib/modules/KERNEL_VERSION/modules.pcimap. After depmod completes, all PCI devices that are supported by modules in the kernel are listed, along with their module names, in that file. When the kernel tells the hotplug system that a new PCI device has been found, the hotplug system uses the modules.pcimap file to find the proper driver to load.

/* Define these values to match your devices */

#define USB_SKEL_VENDOR_ID  0xfff0 
#define USB_SKEL_PRODUCT_ID 0xfff0 
/* table of devices that work with this driver */ 
static struct usb_device_id skel_table [] = { 
     { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 
     { }                    /* Terminating entry */ 
}; 
MODULE_DEVICE_TABLE (usb, skel_table);

MODULE_DEVICE_TABLE的第一个参数是设备的类型,如果是USB设备,那自然是usb(如果是PCI设备,那将是pci,这两个子系统用同一个宏来注册所支持的设备。这涉及PCI设备的驱动了,在此先不深究)。后面一个参数是设备表,这个设备表的最后一个元素是空的,用于标识结束。代码定义了USB_SKEL_VENDOR_ID是0xfff0,USB_SKEL_PRODUCT_ID是0xfff0,也就是说,当有一个设备接到集线器时,usb子系统就会检查这个设备的vendor ID和product ID,如果它们的值是0xfff0时,那么子系统就会调用这个skeleton模块作为设备的驱动。

如果有几个驱动文件同时调用了MODULE_DEVICE_TABLE(pci,***),那么hotplug调用哪个哪个驱动?是不是就是调用该宏的本模块,本module,本驱动。应该是的,看上面红色字部分  along with their module names

类似的有:

    1. MODULE_LICENSE("许可证");
    2. MODULE_AUTHOR("模块作者");
    3. MODULE_DESCRIPTION("模块用途描述");
    4. MODULE_VERSION("代码修订号");
    5. MODULE_ALIAS("模块的别名");
    6. MODULE_DEVICE_TABLE("模块支持的设备")

MODULE_DEVICE_TABLE【转】的更多相关文章

  1. MODULE_DEVICE_TABLE

    1. MODULE_DEVICE_TABLE (usb, skel_table);该宏生成一个名为__mod_pci_device_table的局部变量,该变量指向第二个参数.内核构建时,depmod ...

  2. MODULE_DEVICE_TABLE 的作用

    pci_device_id,PCI设备类型的标识符.在include/linux/mod_devicetable.h头文件中定义.struct pci_device_id {        __u32 ...

  3. MODULE_DEVICE_TABLE (二)【转】

    转自:http://blog.csdn.net/uruita/article/details/7263290 1. MODULE_DEVICE_TABLE (usb, skel_table);该宏生成 ...

  4. MODULE_DEVICE_TABLE的理解【转】

    本文转载自:http://blog.csdn.net/sidely/article/details/39666471 在Linux IIC驱动中看到一段代码: static struct platfo ...

  5. 基於tiny4412的Linux內核移植--- 中斷和GPIO學習(3)

    作者 彭東林 pengdonglin137@163.com 平臺 tiny4412 ADK Linux-4.4.4 u-boot使用的U-Boot 2010.12,是友善自帶的,爲支持設備樹和uIma ...

  6. 基於tiny4412的Linux內核移植--- 中斷和GPIO學習(2)

    作者 彭東林 pengdonglin137@163.com 平臺 tiny4412 ADK Linux-4.4.4 u-boot使用的U-Boot 2010.12,是友善自帶的,爲支持設備樹和uIma ...

  7. 基於tiny4412的Linux內核移植--- 中斷和GPIO學習(1)

    作者 彭東林 pengdonglin137@163.com 平臺 tiny4412 ADK Linux-4.4.4 u-boot使用的U-Boot 2010.12,是友善自帶的,爲支持設備樹和uIma ...

  8. linux platform设备与驱动

    struct platform_driver { int (*probe)(struct platform_device *); int (*remove)(struct platform_devic ...

  9. 学习Linux下s3c2440的USB鼠标驱动笔记

    1.ARM-Linux下USB驱动程序开发1.1.1.linux下USB配置:*********(MassStorage:存储设备)********************************** ...

随机推荐

  1. js浏览器缩放提示

    data() { return { instance: null, isZoomOpen: false }; }, mounted() { const that = this; this.isZoom ...

  2. mysql时间函数和时间操作

    补 原文链接:http://blog.csdn.net/yuxiayiji/article/details/7480785 select timediff('23:40:00', ' 18:30:00 ...

  3. PHP中文字符gbk编码与UTF-8编码的转换

    通常PHP中上传文件,如果文件名称有中文字符,上传之后的名称是无法写入到本地的,因为上传来的编码格式一般是UTF-8的格式,这种格式是无法给文件命名并且存储到操作系统磁盘.在写入之前需要将其转换为gb ...

  4. 一文看尽HashMap

    前言 日常开发中,经常会使用到JDK自带的集合类:List.Set.Map三者的实现,ArrayList.LinkedList.HashSet.TreeSet.HashMap.TreeMap等.其中L ...

  5. linux内核设计与实现一书阅读整理 之第五章

    CHAPTER 5 系统调用 5.1 与内核通信 系统调用在用户空间进程和硬件设备之间添加了一个中间层,该层主要作用有三个: 为用户空间提供了一种硬件的抽象接口 系统调用保证了系统的稳定和安全 每个进 ...

  6. 【django基础之ORM,增删改查】

    一.定义 1.什么是ORM? ORM,即Object-Relational Mapping(对象关系映射),它的作用是在关系型数据库和业务实体对象之间作一个映射,这样,我们在具体的操作业务对象的时候, ...

  7. 那些ie6已支持的方法属性,成为事实标准。或者方便大家的api

    很多api,都是ie6实现,后来其他w3c或其他浏览器支持,或者用类似的方法模拟 onselectionchange  判断选区改变 ,chrome已支持 Element.contains   判断元 ...

  8. python调用powershell、远程执行bat

    python调用本地powershell方法 1.现在准备一个简陋的powershell脚本,功能是测试一个IP列表哪些可以ping通: function test_ping($iplist) { f ...

  9. Maven settings.xml配置(指定本地仓库、阿里云镜像设置)

    转: 详解Maven settings.xml配置(指定本地仓库.阿里云镜像设置) 更新时间:2018年12月18日 11:14:45   作者:AmaniZ   我要评论   一.settings. ...

  10. Netlink 介绍(译)

    原文地址:http://people.redhat.com/nhorman/papers/netlink.pdf 译文: 1 介绍 在Linux和Unix的众多发行版中的网络配置功能, 都是编程者事后 ...