FreeBSD/sys/dev/usb/serial/usb_serial.c
/*
 * The following function will do nothing if the structure pointed to
 * by "ssc" and "sc" is zero or has already been detached.
 */
The following function will do nothing if the structure pointed to
by "ssc" and "sc" is zero or has already been detached.
The following function will do nothing if the structure pointed to by " ssc " and " sc " is zero or has already been detached .
void
ucom_detach(struct ucom_super_softc *ssc, struct ucom_softc *sc)
{
	int subunit;
	if (!(ssc->sc_flag & UCOM_FLAG_ATTACHED))
		return;		
	if (ssc->sc_sysctl_ttyname != NULL) {
		sysctl_remove_oid(ssc->sc_sysctl_ttyname, 1, 0);
		ssc->sc_sysctl_ttyname = NULL;
	}
	if (ssc->sc_sysctl_ttyports != NULL) {
		sysctl_remove_oid(ssc->sc_sysctl_ttyports, 1, 0);
		ssc->sc_sysctl_ttyports = NULL;
	}
	usb_proc_drain(&ssc->sc_tq);
	for (subunit = 0; subunit < ssc->sc_subunits; subunit++) {
		if (sc[subunit].sc_flag & UCOM_FLAG_ATTACHED) {
			ucom_detach_tty(ssc, &sc[subunit]);
			sc[subunit].sc_flag &= ~UCOM_FLAG_ATTACHED;
		}
	}
	usb_proc_free(&ssc->sc_tq);
	ucom_unref(ssc);
	if (ssc->sc_flag & UCOM_FLAG_WAIT_REFS)
		ucom_drain(ssc);
	ssc->sc_flag &= ~UCOM_FLAG_ATTACHED;
}
void ucom_detach ( struct ucom_super_softc * ssc , struct ucom_softc * sc ) { int subunit ; if ( ! ( ssc -> sc_flag & UCOM_FLAG_ATTACHED ) ) return ; if ( ssc -> sc_sysctl_ttyname != NULL ) { sysctl_remove_oid ( ssc -> sc_sysctl_ttyname , 1 , 0 ) ; ssc -> sc_sysctl_ttyname = NULL ; } if ( ssc -> sc_sysctl_ttyports != NULL ) { sysctl_remove_oid ( ssc -> sc_sysctl_ttyports , 1 , 0 ) ; ssc -> sc_sysctl_ttyports = NULL ; } usb_proc_drain ( & ssc -> sc_tq ) ; for ( subunit = 0 ; subunit < ssc -> sc_subunits ; subunit ++ ) { if ( sc [ subunit ] . sc_flag & UCOM_FLAG_ATTACHED ) { ucom_detach_tty ( ssc , & sc [ subunit ] ) ; sc [ subunit ] . sc_flag &= ~ UCOM_FLAG_ATTACHED ; } } usb_proc_free ( & ssc -> sc_tq ) ; ucom_unref ( ssc ) ; if ( ssc -> sc_flag & UCOM_FLAG_WAIT_REFS ) ucom_drain ( ssc ) ; ssc -> sc_flag &= ~ UCOM_FLAG_ATTACHED ; }
The following function will do nothing if the structure pointed to
 by "ssc" and "sc" is zero or has already been detached.
The following function will do nothing if the structure pointed to by " ssc " and " sc " is zero or has already been detached .
/* not initialized */ /* avoid duplicate detach */ /* make sure we don't detach twice */