FreeBSD/sys/dev/usb/misc/udbp.c
/*
 * Dook disconnection
 *
 * For this type, removal of the last link destroys the node
 */
Dook disconnection
For this type, removal of the last link destroys the node
Dook disconnection For this type removal of the last link destroys the node
static int
ng_udbp_disconnect(hook_p hook)
{
	struct udbp_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
	int error = 0;
	if (sc != NULL) {
		mtx_lock(&sc->sc_mtx);
		if (hook != sc->sc_hook) {
			error = EINVAL;
		} else {
			usbd_transfer_stop(sc->sc_xfer[UDBP_T_RD_CS]);
			usbd_transfer_stop(sc->sc_xfer[UDBP_T_RD]);
			usbd_transfer_stop(sc->sc_xfer[UDBP_T_WR_CS]);
			usbd_transfer_stop(sc->sc_xfer[UDBP_T_WR]);
			NG_BT_MBUFQ_DRAIN(&sc->sc_xmitq);
			NG_BT_MBUFQ_DRAIN(&sc->sc_xmitq_hipri);
			if (sc->sc_bulk_in_buffer) {
				m_freem(sc->sc_bulk_in_buffer);
				sc->sc_bulk_in_buffer = NULL;
			}
			sc->sc_hook = NULL;
		}
		mtx_unlock(&sc->sc_mtx);
	}
	if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
	    && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
		ng_rmnode_self(NG_HOOK_NODE(hook));
	return (error);
}
static int ng_udbp_disconnect ( hook_p hook ) { struct udbp_softc * sc = NG_NODE_PRIVATE ( NG_HOOK_NODE ( hook ) ) ; int error = 0 ; if ( sc != NULL ) { mtx_lock ( & sc -> sc_mtx ) ; if ( hook != sc -> sc_hook ) { error = EINVAL ; } else { usbd_transfer_stop ( sc -> sc_xfer [ UDBP_T_RD_CS ] ) ; usbd_transfer_stop ( sc -> sc_xfer [ UDBP_T_RD ] ) ; usbd_transfer_stop ( sc -> sc_xfer [ UDBP_T_WR_CS ] ) ; usbd_transfer_stop ( sc -> sc_xfer [ UDBP_T_WR ] ) ; NG_BT_MBUFQ_DRAIN ( & sc -> sc_xmitq ) ; NG_BT_MBUFQ_DRAIN ( & sc -> sc_xmitq_hipri ) ; if ( sc -> sc_bulk_in_buffer ) { m_freem ( sc -> sc_bulk_in_buffer ) ; sc -> sc_bulk_in_buffer = NULL ; } sc -> sc_hook = NULL ; } mtx_unlock ( & sc -> sc_mtx ) ; } if ( ( NG_NODE_NUMHOOKS ( NG_HOOK_NODE ( hook ) ) == 0 ) && ( NG_NODE_IS_VALID ( NG_HOOK_NODE ( hook ) ) ) ) ng_rmnode_self ( NG_HOOK_NODE ( hook ) ) ; return ( error ) ; }
Dook disconnection
 For this type, removal of the last link destroys the node
Dook disconnection For this type removal of the last link destroys the node
/* stop bulk-in transfer */ /* stop bulk-out transfer */ /* cleanup queues */