一、linux驱动probe调用的整体流程
1、device的创建
(1)代码流程
start_kernel // init/main.c
setup_arch(&command_line);
setup_machine_fdt(__fdt_pointer);
early_init_dt_scan(dt_virt))
early_init_dt_verify(params)
initial_boot_params = params;
unflatten_device_tree();
__unflatten_device_tree(initial_boot_params, NULL, &of_root,early_init_dt_alloc_memory_arch, false);
unflatten_dt_nodes(blob, mem, dad, mynodes);
struct device_node *root;
for (offset = 0;offset >= 0 && depth >= initial_depth;offset -= fdt_next_node(blob, offset, &depth))
populate_node(blob, offset, &mem, nps[depth],&nps[depth+1], dryrun))
pathp = fdt_get_name(blob, offset, &l);
np = unflatten_dt_alloc(mem, sizeof(struct device_node) + allocl,__alignof__(struct device_node));
populate_properties(blob, offset, mem, np, pathp, dryrun);
np->name = of_get_property(np, "name", NULL);
root = nps[depth+1];
arch_initcall_sync(of_platform_default_populate_init); // drivers/of/platform.c
of_platform_default_populate_init
of_platform_default_populate(NULL, NULL, NULL);
of_platform_populate(root, of_default_bus_match_table, lookup,parent);
root = root ? of_node_get(root) : of_find_node_by_path("/");
of_find_node_by_path
of_find_node_opts_by_path
if (strcmp(path, "/") == 0)
return of_node_get(of_root);
for_each

文章详细阐述了Linux驱动probe调用的整体流程,从设备的创建开始,包括device树的解析、platform_device的创建,到driver的创建过程,如module_platform_driver的使用,以及platform_driver_register如何将驱动注册到总线。同时,文章讨论了同一等级module_init的调用顺序、相同IP设备的加载顺序,解释了mmcblkx的变化原因以及生成原理,并提出了通过别名绑定节点和禁用异步方式作为解决问题的方法。
最低0.47元/天 解锁文章
4415

被折叠的 条评论
为什么被折叠?



