三、platform_driver的注册
driver部分比较简单,其结构为:
struct platform_driver {
int (*probe)(struct platform_device *);
int (*remove)(struct platform_device *);
void (*shutdown)(struct platform_device *);
int (*suspend)(struct platform_device *, pm_message_t state);
int (*resume)(struct platform_device *);
struct device_driver driver; //内嵌的标准driver结构
const struct platform_device_id *id_table; //支持的设备id表
};
注册函数分析:
int platform_driver_register(struct platform_driver *drv)
{
drv->driver.bus = &platform_bus_type; //设置bus
if (drv->probe) //如果platform_driver下的probe为真,就把内嵌
drv->driver.probe = platform_drv_probe; //的标准driver的probe设置成platform_drv_probe
if (drv->remove) //可见外层的probe比内层的优先级别高
drv->driver.remove = platform_drv_remove;
if (drv->shutdown)
drv->driver.shutdown = platform_drv_shutdown;
return driver_register(&drv->driver); //注册标准driver
}
四、总结
分析了platform架构以及初始化以及注册流程,结合前面关于标注模型的理解,理解这部分,应当很简单! ^_^
