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

Function rt_bus_add_device

components/drivers/core/bus.c:279–294  ·  view source on GitHub ↗

* @brief This function add a device to the dev_list of a specific bus * * @param bus the bus to add * * @param dev the device to be added * * @return the error code, RT_EOK on added successfully. */

Source from the content-addressed store, hash-verified

277 * @return the error code, RT_EOK on added successfully.
278 */
279rt_err_t rt_bus_add_device(rt_bus_t bus, rt_device_t dev)
280{
281 RT_ASSERT(bus != RT_NULL);
282 RT_ASSERT(dev != RT_NULL);
283
284 dev->bus = bus;
285 rt_list_init(&dev->node);
286
287 _dm_bus_lock(&bus->dev_lock);
288 rt_list_insert_before(&bus->dev_list, &dev->node);
289 _dm_bus_unlock(&bus->dev_lock);
290
291 rt_bus_for_each_drv(bus, dev, bus_probe_device);
292
293 return RT_EOK;
294}
295
296/**
297 * @brief This function remove a driver from bus

Callers 6

rt_pci_device_registerFunction · 0.85
rt_spi_device_registerFunction · 0.85
rt_phy_device_registerFunction · 0.85
rt_i2c_device_registerFunction · 0.85

Calls 5

rt_list_initFunction · 0.85
_dm_bus_lockFunction · 0.85
rt_list_insert_beforeFunction · 0.85
_dm_bus_unlockFunction · 0.85
rt_bus_for_each_drvFunction · 0.85

Tested by

no test coverage detected