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

Function rt_bus_remove_device

components/drivers/core/bus.c:339–375  ·  view source on GitHub ↗

* @brief This function remove a device from bus * * @param dev the device to be removed * * @return the error code, RT_EOK on added successfully. */

Source from the content-addressed store, hash-verified

337 * @return the error code, RT_EOK on added successfully.
338 */
339rt_err_t rt_bus_remove_device(rt_device_t dev)
340{
341 rt_bus_t bus;
342 rt_driver_t drv;
343 rt_err_t err = RT_EOK;
344
345 RT_ASSERT(dev != RT_NULL);
346 RT_ASSERT(dev->bus != RT_NULL);
347
348 bus = dev->bus;
349 drv = dev->drv;
350
351 LOG_D("Bus(%s) remove device %s", bus->name, dev->parent.name);
352
353 _dm_bus_lock(&bus->dev_lock);
354 rt_list_remove(&dev->node);
355 _dm_bus_unlock(&bus->dev_lock);
356
357 if (dev->bus->remove)
358 {
359 err = dev->bus->remove(dev);
360 }
361 else if (drv)
362 {
363 if (drv->remove)
364 {
365 err = drv->remove(dev);
366 }
367
368 /* device and driver are in the same bus */
369 _dm_bus_lock(&bus->drv_lock);
370 --drv->ref_count;
371 _dm_bus_unlock(&bus->drv_lock);
372 }
373
374 return err;
375}
376
377struct bus_shutdown_info
378{

Callers 1

pci_remove_bus_deviceFunction · 0.85

Calls 3

_dm_bus_lockFunction · 0.85
rt_list_removeFunction · 0.85
_dm_bus_unlockFunction · 0.85

Tested by

no test coverage detected