驱动注册并调用probe的过程

驱动注册

  1. driver_register接口的调用,一般wrapper后的调用,platform_driver_register/i2c_add_driver
    ./drivers/base/platform.c定义了platform_driver_register
    driver_register—->bus_add_driver—->driver_attach—->bus_for_each_dev—->__driver_attach—->driver_probe_device
    默认的platform_driver_register传入的参数为platform_driver指针,总线类型默认初始化为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,  
};  
发布了38 篇原创文章 · 获赞 5 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/zhiyanzhai563/article/details/79473802