How to platform and platform device driver matching [turn]

Transfer: https://www.cnblogs.com/sky-heaven/p/6869591.html

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https: //blog.csdn.net/Obsession2015/article/details/77933852

device aspects:

platform_device_register(struct platform_device *dev)
------platform_device_add(pdev);
----------device_add(&pdev->dev);
--------------bus_probe_device(dev);
-------------------device_attach(dev);
-------------------------bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
-------------------------------driver_match_device(drv, dev);成功才向下执行probe!
-------------------------------------driver_probe_device(drv, dev);
--------------------------------------------really_probe(dev, drv);
----------------------------------------------------dev->bus->probe(dev);或者drv->probe(dev);platform_device_add(pdev);

driver aspects:
platform_driver_register (struct platform_driver * DRV)
-------- driver_register (& Drv-> driver);
----------------------- bus_add_driver (DRV);
------- driver_attach ---------- (DRV);
------------------------ bus_for_each_dev (Drv-> Bus, NULL, DRV, __driver_attach); traversing all nodes!
------------------------------- driver_match_device (drv, dev); only successful execution down probe!
driver_probe_device --------------------------------------- (drv, dev);
---- -------------------------------------------- really_probe (dev, drv) ;
------------------------------------------------- -------- dev-> bus-> probe (dev ); or drv-> probe (dev);


driver_match_device () is the key match, in essence, on the implementation:
-------- return Drv-> BUS-> match Drv-> BUS-> match (dev, drv):? 1;
----- -------------. match = platform_match final call bus in platform_match function to match.


bus_for_each_drv / dev () function:
--------- the while (! (dev = next_device (& I)) && error) traverse all nodes;
--------------- error = fn (dev, data) ; id_table matching method can be used to match a plurality of devices.
----------------
Disclaimer: This article is CSDN blogger "Linux anonymous" in the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and link this statement.
Original link: https: //blog.csdn.net/obsession2015/article/details/77933852

Guess you like

Origin www.cnblogs.com/sky-heaven/p/11867497.html