* @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. */
| 277 | * @return the error code, RT_EOK on added successfully. |
| 278 | */ |
| 279 | rt_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 |
no test coverage detected