platform_driver_register()
driver_register()
driver_find()(確定driver沒有被註冊)
bus_add_driver()
driver_attach()(匹配dev-driver並綁定)
bus_for_each_dev()(搜索設備鏈表裏的所有設備)
__driver_attach()
driver_match_device()(調用總線的platform_match匹配函數 比對of_match_table)
driver_probe_device()(匹配上就調用總線的probe 如果沒有就調用drv的probe)
module_add_driver()
driver_create_file()
driver_add_attrs()
i2c_add_driver(&drv_i2c_driver);
i2c_register_driver(THIS_MODULE, driver)
driver_register(&driver->driver);
bus_add_driver(drv);
driver_attach(drv);
bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); //循環查找總線上所有dev
__driver_attach(drv); //返回一直是0
driver_match_device(drv, dev);//檢測能夠匹配上的dev 如果匹配上返回i2c_device_match結果1
drv->bus->match(dev, drv)
i2c_device_match(struct device *dev, struct device_driver *drv)//如果匹配上返回1
of_driver_match_device(dev, drv) //如果匹配上了就會返回一個of_device_id指針
of_match_device(drv->of_match_table, dev)
of_match_node(matches, dev->of_node);
__of_match_node(matches, node);比較"compatible"的名字
match =match &( __of_device_is_compatible(node,matches->compatible));
driver_probe_device(drv, dev);//如果dev沒有和驅動綁定過則調用probe
really_probe(dev, drv);
i2c_device_probe(struct device *dev)//總線probe 設備驅動裏一定要有id_table和probe否則返回錯誤
driver->probe(client, i2c_match_id(driver->id_table, client));//驅動probe 獲取dev資源i2c_client已經包含了所有特定必要資源
i2c_for_each_dev(driver, __process_new_driver);//
__process_new_driver(struct device *dev, void *data)
i2c_do_add_adapter(data, to_i2c_adapter(dev));
i2c_detect(adap, driver);//如果i2c_driver定義了detect和address_list 將i2c_cliect和i2c_driver以及i2c_adapter相連
i2c_detect_address(temp_client, driver);//檢查設備地址是否已被使用並且有效(發送數據等待實際硬件是否有迴應)
driver->detect(temp_client, &info);//調用設備驅動裏的detect函數進行檢測實際硬件是否存在
driver->attach_adapter(adap);//如果i2c_driver定義了attach_adapter 進行檢測實際硬件是否存在
在設備驅動的probe裏就可以去查詢有沒有真正的硬件設備比如at24c02,如果有就可以建立設備節點,提供file_operation裏的open,write函數