FreeBSD/sys/dev/mps/mps.c
/*
 * Free all of the driver resources and detach submodules.  Should be called
 * without the lock held.
 */
Free all of the driver resources and detach submodules.  Should be called
without the lock held.
Free all of the driver resources and detach submodules . Should be called without the lock held .
int
mps_free(struct mps_softc *sc)
{
	int error;
	mps_lock(sc);
	sc->mps_flags |= MPS_FLAGS_SHUTDOWN;
	mps_unlock(sc);
	callout_drain(&sc->periodic);
	if (((error = mps_detach_log(sc)) != 0) ||
	    ((error = mps_detach_sas(sc)) != 0))
		return (error);
	mps_detach_user(sc);
	mps_lock(sc);
	if ((error = mps_transition_ready(sc)) != 0) {
		mps_unlock(sc);
		return (error);
	}
	mps_unlock(sc);
	if (sc->facts != NULL)
		free(sc->facts, M_MPT2);
	mps_iocfacts_free(sc);
	if (sc->sysctl_tree != NULL)
		sysctl_ctx_free(&sc->sysctl_ctx);
	if (sc->shutdown_eh != NULL)
		EVENTHANDLER_DEREGISTER(shutdown_final, sc->shutdown_eh);
	mtx_destroy(&sc->mps_mtx);
	return (0);
}
int mps_free ( struct mps_softc * sc ) { int error ; mps_lock ( sc ) ; sc -> mps_flags |= MPS_FLAGS_SHUTDOWN ; mps_unlock ( sc ) ; callout_drain ( & sc -> periodic ) ; if ( ( ( error = mps_detach_log ( sc ) ) != 0 ) || ( ( error = mps_detach_sas ( sc ) ) != 0 ) ) return ( error ) ; mps_detach_user ( sc ) ; mps_lock ( sc ) ; if ( ( error = mps_transition_ready ( sc ) ) != 0 ) { mps_unlock ( sc ) ; return ( error ) ; } mps_unlock ( sc ) ; if ( sc -> facts != NULL ) free ( sc -> facts , M_MPT2 ) ; mps_iocfacts_free ( sc ) ; if ( sc -> sysctl_tree != NULL ) sysctl_ctx_free ( & sc -> sysctl_ctx ) ; if ( sc -> shutdown_eh != NULL ) EVENTHANDLER_DEREGISTER ( shutdown_final , sc -> shutdown_eh ) ; mtx_destroy ( & sc -> mps_mtx ) ; return ( 0 ) ; }
Free all of the driver resources and detach submodules.
Free all of the driver resources and detach submodules .
/* Turn off the watchdog */ /* Lock must not be held for this */ /* Put the IOC back in the READY state. */ /*
	 * Free all buffers that are based on IOC Facts.  A Diag Reset may need
	 * to free these buffers too.
	 */ /* Deregister the shutdown function */