struct bus_type platform_bus_type = { .name = "platform", .dev_attrs = platform_dev_attrs, .match = platform_match, .uevent = platform_uevent, .pm = &platform_dev_pm_ops, };
Platform总线并没有对bus_type进行封装,总线维护了两条链klist_devices和klist_drivers(这两条链表在成员subsys_private下):
Klist_devices 用来连接所有的platformdevice,调用platform_device_register函数时,会把设备挂接到klist_devices链表上;
Klist_drivers 用来连接所有的platformdriver,调用platform_driver_register函数时,会把驱动挂接到klist_drivers链表上。
驱动和设备通过match函数来进行匹配
static int platform_match(struct device*dev, struct device_driver *drv) { structplatform_device *pdev = to_platform_device(dev); structplatform_driver *pdrv = to_platform_driver(drv); /*Attempt an OF style match first */ if(of_driver_match_device(dev, drv)) return1; /*Then try to match against the id table */ if(pdrv->id_table) returnplatform_match_id(pdrv->id_table, pdev) != NULL; /*fall-back to driver name match */ return(strcmp(pdev->name, drv->name) == 0); }