很难理解 MODULE_DEVICE_TABLE(usb, id_table) 的用法 [英] Hard time in understanding MODULE_DEVICE_TABLE(usb, id_table) usage

查看:17
本文介绍了很难理解 MODULE_DEVICE_TABLE(usb, id_table) 的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解MODULE_DEVICE_TABLE(usb, id_table)

AFAIK 这将生成稍后由 modprobe 使用的地图文件,每当插入新设备时,它都会将其与这些地图文件进行匹配,并在匹配时加载模块.

AFAIK this will generate the map files that will be used later by modprobe whenever a new device is inserted, it will match it against those map files and load the module if it matches.

但我的误解是模块不是已经加载了吗?"

But my misunderstanding is "isn't the module loaded anyway?"

我的意思是我在执行 insmod module-name 时已经加载了它.还是我遗漏了什么?

I mean I already loaded it when I did insmod module-name. or am I missing something?

推荐答案

它通常用于支持热插拔,通过加载/插入设备的驱动程序(如果尚未加载).

It is usually used to support hot-plugging, by loading/inserting the driver for a device if not already loaded.

这里有一个类似的问题:在 Linux 中热插拔设备时检测设备的存在

There is a similar question here: Detect the presence of a device when it's hot plugged in Linux

(来自我的回答)

它的工作原理如下:

  1. 代码中的每个驱动程序使用以下方法公开其供应商/设备 ID:

  1. Each driver in the code exposes its vendor/device id using:

  MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);

  • 在编译时,构建过程从所有驱动程序中提取此信息并准备设备表.

  • At compilation time the build process extracts this infomation from all the drivers and prepares a device table.

    当您插入设备时,内核会引用设备表,如果找到与添加设备的设备/供应商 ID 匹配的条目,则加载并初始化其模块.

    When you insert the device, the device table is referred by the kernel and if an entry is found matching the device/vendor id of the added device, then its module is loaded and initialized.

    这篇关于很难理解 MODULE_DEVICE_TABLE(usb, id_table) 的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆