在Linux热插拔时检测设备的存在 [英] Detect the presence of a device when it's hot plugged in Linux
问题描述
我正在运行SPI 代码我想知道中的哪个功能代码负责在设备热插拔时对其进行检测.
I am running the SPI code on the panda board and I want to know which function in the code is responsible for detecting the device when it's hot plugged.
可以请具有嵌入式系统,Linux设备驱动程序和/或spi背景的人回答我的问题吗?
Can somebody with the background of embedded systems, Linux device drivers and/or spi please answer my question?
推荐答案
这是代码中执行魔术的行:
This is the line in your code that does the magic:
1286 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
过程:
1.每个设备的驱动程序使用API MODULE_DEVICE_TABLE
公开其信息.每个设备都有唯一的vendor Id
和device Id
.
2.在编译时,构建过程将从驱动程序中提取此信息并构建表.
3.插入设备后,kernel
会检查此device table
以查看是否有任何driver
适用于特定的Vendor/Device Id
.如果是,则它将加载该驱动程序并初始化设备.
Process:
1. Driver for each device exposes its information using the API MODULE_DEVICE_TABLE
. Each device has a unique vendor Id
and device Id
.
2. At compilation time, the build process extracts this information out of the driver and builds a table.
3. When the device is plugged in, the kernel
checks this device table
to see if any driver
is
available for the particular Vendor/Device Id
. If yes then it loads that driver and initializes the device.
阅读以下文章以了解更多信息:
Read following articles for more info:
- http://www.linux-mag.com/id/2617/
- http://www.linuxjournal.com/node/5604/print
这篇关于在Linux热插拔时检测设备的存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!