示例#1
0
static int
usie_detach(device_t self)
{
    struct usie_softc *sc = device_get_softc(self);
    uint8_t x;

    /* detach ifnet */
    if (sc->sc_ifp != NULL) {
        usie_if_stop(sc);
        usbd_transfer_unsetup(sc->sc_if_xfer, USIE_IF_N_XFER);
        bpfdetach(sc->sc_ifp);
        if_detach(sc->sc_ifp);
        if_free(sc->sc_ifp);
        sc->sc_ifp = NULL;
    }
    /* detach ucom */
    if (sc->sc_nucom > 0)
        ucom_detach(&sc->sc_super_ucom, sc->sc_ucom);

    /* stop all USB transfers */
    usbd_transfer_unsetup(sc->sc_if_xfer, USIE_IF_N_XFER);

    for (x = 0; x != USIE_UCOM_MAX; x++)
        usbd_transfer_unsetup(sc->sc_uc_xfer[x], USIE_UC_N_XFER);


    device_claim_softc(self);

    usie_free_softc(sc);

    return (0);
}
示例#2
0
文件: uhso.c 项目: vkhromov/freebsd
static int
uhso_detach(device_t self)
{
	struct uhso_softc *sc = device_get_softc(self);
	int i;

	usbd_transfer_unsetup(sc->sc_xfer, 3);
	usbd_transfer_unsetup(sc->sc_ctrl_xfer, UHSO_CTRL_MAX);
	if (sc->sc_ttys > 0) {
		ucom_detach(&sc->sc_super_ucom, sc->sc_ucom);

		for (i = 0; i < sc->sc_ttys; i++) {
			if (sc->sc_tty[i].ht_muxport != -1) {
				usbd_transfer_unsetup(sc->sc_tty[i].ht_xfer,
				    UHSO_CTRL_MAX);
			}
		}

		free(sc->sc_tty, M_USBDEV);
		free(sc->sc_ucom, M_USBDEV);
	}

	if (sc->sc_ifp != NULL) {
		callout_drain(&sc->sc_c);
		free_unr(uhso_ifnet_unit, sc->sc_ifp->if_dunit);
		mtx_lock(&sc->sc_mtx);
		uhso_if_stop(sc);
		bpfdetach(sc->sc_ifp);
		if_detach(sc->sc_ifp);
		if_free(sc->sc_ifp);
		mtx_unlock(&sc->sc_mtx);
		usbd_transfer_unsetup(sc->sc_if_xfer, UHSO_IFNET_MAX);
	}

	device_claim_softc(self);

	uhso_free_softc(sc);

	return (0);
}