将参数传递给驱动程序探测函数

passing arguments to drivers probe function

在 module_i2c_driver() 的调用链中,我无法找到将参数传递给函数 adxl34x_i2c_probe() 的位置。

    static int adxl34x_i2c_probe(struct i2c_client *client,
 78                                        const struct i2c_device_id *id)
 79 {
            ...
 99         return 0;
100 }

158 static struct i2c_driver adxl34x_driver = {
159         .driver = {
160                 .name = "adxl34x",
161                 .owner = THIS_MODULE,
162                 .pm = &adxl34x_i2c_pm,
163                 .of_match_table = of_match_ptr(adxl34x_of_id),
164         },
165         .probe    = adxl34x_i2c_probe,
166         .remove   = adxl34x_i2c_remove,
167         .id_table = adxl34x_id,
168 };
169 
170 module_i2c_driver(adxl34x_driver);

i2c_driverprobe 回调从 i2c_device_probe 函数 (http://lxr.free-electrons.com/source/drivers/i2c/i2c-core.c#L632) 调用。

.probe    = adxl34x_i2c_probe

您将 probe 的回调函数指针设置为指向 adx134x_i2c_probe,因此使用传递的参数调用 driver->probe (http://lxr.free-electrons.com/source/drivers/i2c/i2c-core.c#L672) 实际上是调用 adxl34x_i2c_probe 具有相同的参数。