i2c_device_match(),匹配总线维护的驱动链表和设备信息链表,如果其中名字完全相同,则返回true,否则false; i2c_device_probe(),当我们注册一个i2c_drive或者i2c_client结构体时,会从对应的链表中查找节点,并通过i2c_device_match函数比较,如果匹配成功,则调用i2c_drive中定义的probe函数,即o
i2c_device_probe函数执行了 I2C 设备的探测操作。它设置中断信息、处理唤醒功能、设置时钟、关联功耗域,并调用驱动程序的probe函数进行设备特定的探测操作。 staticinti2c_device_probe(structdevice *dev) { structi2c_client*client=i2c_verify_client(dev); structi2c_driver*driver; intstatus; if(!client) retur...
在I2C驱动的probe函数中,通常需要传入一个指向struct i2c_client结构体的指针作为参数。这个结构体是I2C设备在内核中的表示,包含了I2C设备的位置区域、总线信息、驱动信息等。通过这个参数,我们可以获取I2C设备的各种信息,并进行相应的初始化和配置。 2. const struct i2c_device_id *id 另一个常见的参数是一个指向...
i2c_device_probe i2c_match_id 你以为上面设置就好了吗?我们看到 static struct i2c_driver goodix_ts_driver = { .probe = goodix_ts_probe, .remove = goodix_ts_remove, .id_table = goodix_ts_id, .driver = { .name = GTP_I2C_NAME, .owner = THIS_MODULE, .of_match_table = of_m...
int (*probe)(struct i2c_client *, const struct i2c_device_id *): 指向驱动程序的探测函数。当一个新的 I2C 设备与驱动程序匹配时,将调用该函数进行初始化和配置。 int (*remove)(struct i2c_client *): 表示驱动程序的移除函数。当一个已经存在的 I2C 设备与驱动程序不再匹配时,将调用该函数进行清理和...
.probe =i2c_device_probe, .remove = i2c_device_remove, .shutdown = i2c_device_shutdown, }; EXPORT_SYMBOL_GPL(i2c_bus_type); static int __init i2c_init(void) { int retval; retval = of_alias_get_highest_id("i2c"); down_write(&__i2c_board_lock); ...
int (*match)(struct device *dev, struct device_driver *drv); int (*uevent)(struct device *dev, struct kobj_uevent_env *env); int (*probe)(struct device *dev); int (*remove)(struct device *dev); void (*shutdown)(struct device *dev); ...
在给Xilinx Versal的Linux Kernel添加i2c驱动后,发现probe函数没有被执行。 检查编译过程,i2c驱动被编译成了ko文件。 检查编单板的文件系统,i2c驱动已经在文件系统中。 手动加载ko文件,linux报告驱动已经存在。 卸载驱动后,再手动加载ko文件,执行正常,linux没有报告错误。检查内核输出,没有probe里的printk打印,即使是er...
这里以rk3x_i2c_probe为例给大家进行分析: staticintrk3x_i2c_probe(structplatform_device*pdev) { structdevice_node*np=pdev->dev.of_node; conststructof_device_id*match; structrk3x_i2c*i2c; structresource*mem; intret=0; intbus_nr;
=NULL;我们回到i2c_device_probe;这个函数的关键是:status=driver->probe(client,i2c_match_id(driver->id_table,client));它将函数的流程交回到了driver->probe的手中;流程图:过程分享:1、设备和驱动的关联大家知道,对于一个驱动程序有两个元素不可或缺,即设备和驱动,一般驱动都是通过设备名和驱动名的匹配...