请教大家 linux-2.6.22.6中i2c_register_driver() 中drivers,adapters在哪儿定义的?
本文是原「蜗窝讨论区」的历史存档(2016-12-17),来自版块「Linux kernel技术问答」,共 2 帖。讨论区已停止服务,此处仅供查阅。
int i2c_register_driver(struct module owner, struct i2c_driver driver) { int res;
/* new style driver methods can't mix with legacy ones */
if (is_newstyle_driver(driver)) {
if (driver->attach_adapter || driver->detach_adapter
|| driver->detach_client) {
printk(KERN_WARNING
"i2c-core: driver [%s] is confused\n",
driver->driver.name);
return -EINVAL;
}
}
/* add the driver to the list of i2c drivers in the driver core */
driver->driver.owner = owner;
driver->driver.bus = &i2c_bus_type;
/* for new style drivers, when registration returns the driver core
- will have called probe( for all matching-but-unbound devices.
*/
res = driver_register(&driver->driver);
if (res)
return res;
mutex_lock(&core_lists);
list_add_tail(&driver->list,&drivers); //drivers在哪儿定义的?
pr_debug(“i2c-core: driver [%s] registered\n”, driver->driver.name);
/* legacy drivers scan i2c busses directly */
if (driver->attach_adapter) {
struct i2c_adapter *adapter;
list_for_each_entry(adapter, &adapters, list) { //adatpters在哪儿定义的
driver->attach_adapter(adapter);
}
}
mutex_unlock(&core_lists);
return 0;
}
wall-E 写道: int i2c_register_driver(struct module owner, struct i2c_driver driver) { int res;
/* new style driver methods can't mix with legacy ones */
if (is_newstyle_driver(driver)) {
if (driver->attach_adapter || driver->detach_adapter
|| driver->detach_client) {
printk(KERN_WARNING
"i2c-core: driver [%s] is confused\n",
driver->driver.name);
return -EINVAL;
}
}
/* add the driver to the list of i2c drivers in the driver core */
driver->driver.owner = owner;
driver->driver.bus = &i2c_bus_type;
/* for new style drivers, when registration returns the driver core
- will have called probe( for all matching-but-unbound devices.
*/
res = driver_register(&driver->driver);
if (res)
return res;
mutex_lock(&core_lists);
list_add_tail(&driver->list,&drivers); //drivers在哪儿定义的?
pr_debug(“i2c-core: driver [%s] registered\n”, driver->driver.name);
/* legacy drivers scan i2c busses directly */
if (driver->attach_adapter) {
struct i2c_adapter *adapter;
list_for_each_entry(adapter, &adapters, list) { //adatpters在哪儿定义的
driver->attach_adapter(adapter);
}
}
mutex_unlock(&core_lists);
return 0;
}
grep一下总能找得着啊,手上没有你这个版本的代码,就不帮你找了……
