int (*probe_new)(struct i2c_client *client); void (*shutdown)(struct i2c_client *client); void (*alert)(struct i2c_client *client, enum i2c_alert_protocol protocol, unsigned int data); int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); struct device_driver drive...
去"class"下的I2C适配器,用"detect"函数来确定能否找到"address_list"里的设备,如果能找到就调用i2c_new_device来注册i2c_client, 这会和i2c_driver的id_table比较,如果匹配,调用"probe"函数。 流程大致如下 调用i2c_add_driver(i2c_register_driver)将driver添加至i2c_bus_type的i2c driver链表;并且将所有匹配的...
在前面我们已经列出了i2c_driver挂载的i2c总线,match函数指针指向i2c_device_match函数 staticinti2c_device_match(structdevice *dev,structdevice_driver *drv) { struct i2c_client *client = to_i2c_client(dev); //使用container_of获取i2c_client struct i2c_driver *driver = to_i2c_driver(drv);//使用co...
这种方法就是“认为i2c设备一定肯定存在”后直接使用 i2c_new_device函数来注册i2c_client。看看怎样做,再来详细跟进这个函数: 1structi2c_client *i2c_new_device(structi2c_adapter *adap,structi2c_board_infoconst*info)2{3structi2c_client *client;4intstatus;56client = kzalloc(sizeof*client, GFP_KERNEL)...
这种方法就是“认为i2c设备一定肯定存在”后直接使用 i2c_new_device函数来注册i2c_client。看看怎样做,再来详细跟进这个函数: 1 struct i2c_client *i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) 2 { 3 struct i2c_client *client; ...
int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); int (*remove)(struct i2c_client *client); /* New driver model interface to aid the seamless removal of the * current probe()'s, more commonly unused than used second parameter. ...
分析i2c_new_device()函数简化流程如下: 函数流程如下: 分配一个client内存 用参数adap、info初始化client 注册client 分析i2c_register_driver()函数简化流程如下: 函数流程如下: 注册driver 对bus上的每个adapter调用__process_new_driver()函数 bus上的dev出来client外,还有adapter,一个CPU上可以有多个adapter; ...
存储设备私有数据,通常使用i2c_set_clientdata函数将私有数据与i2c_client相关联,方便后续的操作函数访问。 我们在学习其他设备驱动的时候就知道了probe函数是设备与驱动匹配成功后被调用执行的。它的原型通常如下所示: staticint i2c_device_probe(struct i2c_client *client, const struct i2c_device_id *id); ...
struct i2c_client*i2c_new_device(struct i2c_adapter*adap,struct i2c_board_infoconst*info){client->adapter=adap;//i2c_client绑定adapterclient->dev.parent=&client->adapter->dev;client->dev.bus=&i2c_bus_type;client->dev.type=&i2c_client_type;client->dev.of_node=info->of_node;client->dev...
structi2c_client*i2c_new_device(structi2c_adapter*adap,structi2c_board_infoconst*info){client->adapter=adap;//i2c_client绑定adapterclient->dev.parent=&client->adapter->dev;client->dev.bus=&i2c_bus_type;client->dev.type=&i2c_client_type;client->dev.of_node=info->of_node;client->dev.fwno...