sys/kern/subr_bus.c
/**
 * @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.
 */
@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.
@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 .
int
bus_generic_detach(device_t dev)
{
	device_t child;
	int error;
	if (dev->state != DS_ATTACHED)
		return (EBUSY);
	TAILQ_FOREACH(child, &dev->children, link) {
		if ((error = device_detach(child)) != 0)
			return (error);
	}
	return (0);
}
int bus_generic_detach ( device_t dev ) { device_t child ; int error ; if ( dev -> state != DS_ATTACHED ) return ( EBUSY ) ; TAILQ_FOREACH ( child , & dev -> children , link ) { if ( ( error = device_detach ( child ) ) != 0 ) return ( error ) ; } return ( 0 ) ; }
@brief Helper function for implementing DEVICE_DETACH()
 This function can be used to help implement the DEVICE_DETACH() for
 a bus.
@brief Helper function for implementing DEVICE_DETACH () This function can be used to help implement the DEVICE_DETACH () for a bus .