MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / i2c_match

Function i2c_match

components/drivers/i2c/dev_i2c_bus.c:91–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91static rt_bool_t i2c_match(rt_driver_t drv, rt_device_t dev)
92{
93 const struct rt_i2c_device_id *id;
94 struct rt_i2c_driver *driver = rt_container_of(drv, struct rt_i2c_driver, parent);
95 struct rt_i2c_client *client = rt_container_of(dev, struct rt_i2c_client, parent);
96
97 if ((id = driver->ids))
98 {
99 for (; id->name[0]; ++id)
100 {
101 if (!rt_strcmp(id->name, client->name))
102 {
103 client->id = id;
104 client->ofw_id = RT_NULL;
105
106 return RT_TRUE;
107 }
108 }
109 }
110
111#ifdef RT_USING_OFW
112 client->ofw_id = rt_ofw_node_match(client->parent.ofw_node, driver->ofw_ids);
113
114 if (client->ofw_id)
115 {
116 client->id = RT_NULL;
117
118 return RT_TRUE;
119 }
120#endif
121
122 return RT_FALSE;
123}
124
125static rt_err_t i2c_probe(rt_device_t dev)
126{

Callers

nothing calls this directly

Calls 2

rt_strcmpFunction · 0.85
rt_ofw_node_matchFunction · 0.85

Tested by

no test coverage detected