回答
spi-omap2-mcspi.c
的探測功能保存在static struct platform_driver omap2_mcspi_driver
中,該文件已在module_platform_driver(omap2_mcspi_driver);
(在文件末尾)註冊。該module_platform_driver
宏,在platform_device.h定義將結構傳遞到platform_driver_register
宏觀和__platform_driver_register
功能從drivers/base/platform.c
527 /**
528 * __platform_driver_register - register a driver for platform-level devices
529 * @drv: platform driver structure
530 * @owner: owning module/driver
531 */
532 int __platform_driver_register(struct platform_driver *drv,
533 struct module *owner)
534 {
...
536 drv->driver.bus = &platform_bus_type;
537 if (drv->probe)
538 drv->driver.probe = platform_drv_probe;
...
544 return driver_register(&drv->driver);
545 }
546 EXPORT_SYMBOL_GPL(__platform_driver_register);
現在傳遞給driver_register
功能的探頭從drivers/base/driver.c
139 /**
140 * driver_register - register driver with bus
141 * @drv: driver to register
142 *
143 * We pass off most of the work to the bus_add_driver() call,
144 * since most of the things we have to do deal with the bus
145 * structures.
146 */
147 int driver_register(struct device_driver *drv)
148 {
...
154 if ((drv->bus->probe && drv->probe) ||
...
167 ret = bus_add_driver(drv);
...
178 }
所以,現在的司機被註冊公共汽車(platform_bus_type
)。
到探頭實際呼叫通過driver_probe_device
drivers/base/dd.c做了,那麼really_probe
(同一文件行265):
265 static int really_probe(struct device *dev, struct device_driver *drv)
266 {
...
270 pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
271 drv->bus->name, __func__, drv->name, dev_name(dev));
...
287 if (dev->bus->probe) {
288 ret = dev->bus->probe(dev); /// <<<< HERE
289 if (ret)
290 goto probe_failed;
291 } else if (drv->probe) {
292 ret = drv->probe(dev); /// <<<< OR HERE
293 if (ret)
294 goto probe_failed;
295 }
296
297 driver_bound(dev);
298 ret = 1;
299 pr_debug("bus: '%s': %s: bound device %s to driver %s\n",
300 drv->bus->name, __func__, dev_name(dev), drv->name);
301 goto done;
感謝您的回答。 你能解釋一下呼叫鏈嗎? 當設備連接時如何通知驅動程序? –
真的我不能。我只能搜索代碼或在互聯網上的一些網站,可能是這樣的:http://www.cprogramdevelop.com/1120807/「註冊階段:Platform_driver_register()> driver_register()> bus_add_driver()> driver_attach()> bus_for_each_dev ),在每一個掛起的平臺上。設備爲__driver_attach(),driver_probe_device()確定drv-> bus-> match()成功執行,通過指針執行platform_match> strncmp(pdev> name, drv> name,BUS_ID_SIZE)調用really_probe(實際相應的設備platform_driver> probe(platform_device)) – osgx
這是一個非常有用的鏈接。謝謝! –
- 1. 其中是在linux內核中調用的pci驅動程序的探測功能
- 2. 聲音/ soc /編解碼器i2c驅動程序不會探測
- 3. Linux內核中的驅動程序探測順序
- 4. 360遊戲控制器Linux設備驅動程序問題調用我的探測功能
- 5. 如果設備已插入,Linux USB驅動程序探測器不會調用
- 6. 什麼時候調用Linux內核驅動程序的探測函數?
- 7. 從驅動器UI調用應用程序腳本功能
- 8. 用示例代碼測試mongocxx C++驅動程序
- 9. 自定義PCI驅動程序無法探測設備
- 10. Linux USB設備驅動程序未得到探測
- 11. Linux的USB驅動程序:探測已經插入的設備
- 12. 編寫I2C設備驅動程序時出現探測問題
- 13. 未探測到Linux serdev mfd驅動程序
- 14. Windows驅動程序時間戳功能
- 15. 驅動程序類功能重寫
- 16. 什麼是驅動程序功能?
- 17. USB串行/ CDC功能驅動程序
- 18. jdbc驅動程序的功能
- 19. Genymotion設備沒有從DHCP獲取IP - VirtualBox:未能探測到驅動程序
- 20. Linux設備驅動程序功能測試
- 21. Windows設備驅動程序嗅探/調試
- 22. 誰在C調用的主要功能
- 23. 有誰知道任何示例代碼簡單的震動探測器?
- 24. 如何在用戶模式應用程序中執行驅動程序功能?
- 25. linux驅動程序的功能已知/應用程序可見
- 26. 在PHP代碼中使用ODBC驅動程序連接到MySQL
- 27. 我們如何在linux驅動程序代碼中使用kmalloc
- 28. 驅動程序PsLookupProcessByProcessId錯誤代碼0xc000000b
- 29. 設備驅動程序代碼編譯?
- 30. 驅動程序/代碼簽名
請在 「SPI-OMAP2-mcspi.c」 添加行號 – osgx
行號添加 –
可能(誰調用了驅動程序的probe()](http://stackoverflow.com/questions/7578582/who-calls-the-probe-of-driver) – osgx