* @brief This function add a driver to the drv_list of a specific bus * * @param bus the bus to add * * @param drv the driver to be added * * @return the error code, RT_EOK on added successfully. */
| 251 | * @return the error code, RT_EOK on added successfully. |
| 252 | */ |
| 253 | rt_err_t rt_bus_add_driver(rt_bus_t bus, rt_driver_t drv) |
| 254 | { |
| 255 | RT_ASSERT(bus != RT_NULL); |
| 256 | RT_ASSERT(drv != RT_NULL); |
| 257 | |
| 258 | drv->bus = bus; |
| 259 | rt_list_init(&drv->node); |
| 260 | |
| 261 | _dm_bus_lock(&bus->drv_lock); |
| 262 | rt_list_insert_before(&bus->drv_list, &drv->node); |
| 263 | _dm_bus_unlock(&bus->drv_lock); |
| 264 | |
| 265 | rt_bus_for_each_dev(bus, drv, bus_probe_driver); |
| 266 | |
| 267 | return RT_EOK; |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * @brief This function add a device to the dev_list of a specific bus |
no test coverage detected