Detect the presence of a device when it's hot plugged in Linux

被刻印的时光 ゝ 提交于 2019-12-03 06:59:40

问题


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.

Can somebody with the background of embedded systems, Linux device drivers and/or spi please answer my question?


回答1:


This is the line in your code that does the magic:

1286 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);

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:

  1. http://www.linux-mag.com/id/2617/
  2. http://www.linuxjournal.com/node/5604/print


来源:https://stackoverflow.com/questions/22777644/detect-the-presence-of-a-device-when-its-hot-plugged-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!