Driver registration process and calls for probe

Registration drive

  1. driver_register call interface, called after the general wrapper, platform_driver_register / i2c_add_driver
    ./drivers/base/platform.c defines platform_driver_register
    driver_register -> bus_add_driver -> driver_attach -> bus_for_each_dev -> __ driver_attach -> driver_probe_device
    default platform_driver_register platform_driver pointer parameter is passed, the bus is initialized to the default type platform_bus_type

/**
 * platform_driver_register - register a driver for platform-level devices
 * @drv: platform driver structure
 */
int platform_driver_register(struct platform_driver *drv)
{
    drv->driver.bus = &platform_bus_type;
    if (drv->probe)
        drv->driver.probe = platform_drv_probe;
    if (drv->remove)
        drv->driver.remove = platform_drv_remove;
    if (drv->shutdown)
        drv->driver.shutdown = platform_drv_shutdown;

    return driver_register(&drv->driver);
}
EXPORT_SYMBOL_GPL(platform_driver_register);
struct bus_type platform_bus_type = {  
    .name       = "platform",  
    .dev_attrs  = platform_dev_attrs,  
    .match      = platform_match,  
    .uevent     = platform_uevent,  
    .pm     = &platform_dev_pm_ops,  
};  
Published 38 original articles · won praise 5 · views 20000 +

Guess you like

Origin blog.csdn.net/zhiyanzhai563/article/details/79473802