* @brief Helper function for implementing DEVICE_DETACH() * * This function can be used to help implement the DEVICE_DETACH() for * a bus. It calls device_detach() for each of the device's * children. */
| 3745 | * children. |
| 3746 | */ |
| 3747 | int |
| 3748 | bus_generic_detach(device_t dev) |
| 3749 | { |
| 3750 | device_t child; |
| 3751 | int error; |
| 3752 | |
| 3753 | if (dev->state != DS_ATTACHED) |
| 3754 | return (EBUSY); |
| 3755 | |
| 3756 | /* |
| 3757 | * Detach children in the reverse order. |
| 3758 | * See bus_generic_suspend for details. |
| 3759 | */ |
| 3760 | TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) { |
| 3761 | if ((error = device_detach(child)) != 0) |
| 3762 | return (error); |
| 3763 | } |
| 3764 | |
| 3765 | return (0); |
| 3766 | } |
| 3767 | |
| 3768 | /** |
| 3769 | * @brief Helper function for implementing DEVICE_SHUTDOWN() |
no test coverage detected