8-2-2. drivers/base/dd.c : really_probe(...)
...
dev->driver = drv; // 驱动 赋值给 设备.
pinctrl_bind_pins(); // 跳到第8-2-2-1-1步
...
if (dev->bus->probe) {
ret = dev->bus->probe(dev);
if (ret)
goto probe_failed;
} else if (drv->probe) {
ret = drv->probe(dev); // 前面platform_driver_register(...)时 drv->driver.probe = platform_drv_probe, 所以进入platform_drv_probe
// 跳到第8-2-2-2-1步
if (ret)
goto probe_failed;
}
driver_bound(dev); // 驱动挷定设备
8-2-2-1-1. drivers/base/pinctrl.c : pinctrl_bind_pins(...)
dev->pins = devm_kzalloc(dev, sizeof(*(dev->pins)), GFP_KERNEL);
if (!dev->pins)
return -ENOMEM;
dev->pins->p = devm_pinctrl_get(dev); // 调用 pinctrl_get(...) --> create_pinctrl(...)
// 又进入到pinctrl子系统代码中
// 在create_pinctrl(...)里
// p->states, p->dt_maps都为空, 只有pinctrl-0的dts节点设备才不为空, 具体查看, pinctrl驱动初始化
// 具体查看 基于linux 3.10.49内核的pinctrl流程分析 补充 已介绍过
// 加入到list_add_tail(&p->node, &pinctrl_list);
// 每一个驱动注册时, alloc的struct pinctrl都会加入到全局变量pinctrl_list列表中.
if (IS_ERR(dev->pins->p)) {
dev_dbg(dev, "no pinctrl handle\n");
ret = PTR_ERR(dev->pins->p);
goto cleanup_alloc;
}
dev->pins->default_state = pinctrl_lookup_state(dev->pins->p,
PINCTRL_STATE_DEFAULT); // gpio是没有state, 一般只有pinctrl-0的dts节点设备才存在.
if (IS_ERR(dev->pins->default_state)) {
dev_dbg(dev, "no default pinctrl state\n");
/* printk(">>>>>>>>>>>>>>>>>>>>>>>>>>>> dev_name(dev) = %s\n", dev_name(dev)); */
ret = 0;
goto cleanup_get; // 没有state, ret = 0; 直接goto cleanup_get;
}
8-2-2-2-1. drivers/base/platform.c : platform_drv_probe(...)
...
ret = drv->probe(dev); // struct platform_driver ***_gpio_driver的probe函数.也就是***_gpio_probe, 最终目的来到这里.可以自定义写代码了.
...