注:支持bus device driver模型 都遵循这套流程
platform_driver 注册时,如何遍历platform_bus_type总线上platform_device链表,并且调用platform_bus_type的match函数进行匹配,匹配成功后如何调用platform_driver 的
probe函数
-----------------
device_driver 注册时,如何遍历bus_type总线上device链表,并且调用bus_type的match函数进行匹配,匹配成功后如何调用device_driver 的probe函数
platform_driver_register
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;
driver_register//用platform_driver的probe等函数给device_driver的probe等赋值
ret = bus_add_driver(drv);
error = driver_attach(drv);
bus_for_each_dev(drv->bus, NULL, drv, __driver_attach)
while ((dev = next_device(&i)) && !error)
error = fn(dev, data);//遍历bus_type上的device链表调用fn=__driver_attach
error = __driver_attach(dev, data)
if (!driver_match_device(drv, dev))
return 0;
return drv->bus->match ? drv->bus->match(dev, drv) : 1;//调用drv->bus->match
driver_probe_device(drv, dev)
ret = really_probe(dev, drv);
ret = dev->bus->probe(dev);//bus_type的probe函数
ret = drv->probe(dev);//device_driver的probe函数
================================================================
platform_device 注册时,如何遍历platform_bus_type总线上platform_driver链表,并且调用platform_bus_type的match函数进行匹配,匹配成功后如何调用platform_driver 的
probe函数
-----------------------------------------
device 注册时,如何遍历bus_type总线上driver链表,并且调用bus_type的match函数进行匹配,匹配成功后如何调用device_driver 的probe函数
platform_device_register
platform_device_add
pdev->dev.bus = &platform_bus_type;//设置总线类型
ret = device_add(&pdev->dev);
bus_probe_device(dev);
ret = device_attach(dev);
ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
error = fn(drv, data);
error = __device_attach(drv, data);
if (!driver_match_device(drv, dev))
return 0;
return drv->bus->match ? drv->bus->match(dev, drv) : 1;
return driver_probe_device(drv, dev);
ret = really_probe(dev, drv);
ret = dev->bus->probe(dev);
ret = drv->probe(dev);
总线设备驱动模型:bus->match,driver->probe
最新推荐文章于 2024-07-13 19:58:18 发布