FreeBSD/sys/dev/twe/twe_freebsd.c
/********************************************************************************
 * Free all of the resources associated with (sc).
 *
 * Should not be called if the controller is active.
 */
Free all of the resources associated with (sc).
Should not be called if the controller is active.
Free all of the resources associated with ( sc ) . Should not be called if the controller is active .
static void
twe_free(struct twe_softc *sc)
{
    struct twe_request	*tr;
    debug_called(4);
    while ((tr = twe_dequeue_free(sc)) != NULL)
	twe_free_request(tr);
    if (sc->twe_cmd != NULL) {
	bus_dmamap_unload(sc->twe_cmd_dmat, sc->twe_cmdmap);
	bus_dmamem_free(sc->twe_cmd_dmat, sc->twe_cmd, sc->twe_cmdmap);
    }
    if (sc->twe_immediate != NULL) {
	bus_dmamap_unload(sc->twe_immediate_dmat, sc->twe_immediate_map);
	bus_dmamem_free(sc->twe_immediate_dmat, sc->twe_immediate,
			sc->twe_immediate_map);
    }
    if (sc->twe_immediate_dmat)
	bus_dma_tag_destroy(sc->twe_immediate_dmat);
    if (sc->twe_buffer_dmat)
	bus_dma_tag_destroy(sc->twe_buffer_dmat);
    if (sc->twe_intr)
	bus_teardown_intr(sc->twe_dev, sc->twe_irq, sc->twe_intr);
    if (sc->twe_irq != NULL)
	bus_release_resource(sc->twe_dev, SYS_RES_IRQ, 0, sc->twe_irq);
    if (sc->twe_parent_dmat)
	bus_dma_tag_destroy(sc->twe_parent_dmat);
    if (sc->twe_io != NULL)
	bus_release_resource(sc->twe_dev, SYS_RES_IOPORT, TWE_IO_CONFIG_REG, sc->twe_io);
    if (sc->twe_dev_t != (struct cdev *)NULL)
	destroy_dev(sc->twe_dev_t);
    sx_destroy(&sc->twe_config_lock);
    mtx_destroy(&sc->twe_io_lock);
}
static void twe_free ( struct twe_softc * sc ) { struct twe_request * tr ; debug_called ( 4 ) ; while ( ( tr = twe_dequeue_free ( sc ) ) != NULL ) twe_free_request ( tr ) ; if ( sc -> twe_cmd != NULL ) { bus_dmamap_unload ( sc -> twe_cmd_dmat , sc -> twe_cmdmap ) ; bus_dmamem_free ( sc -> twe_cmd_dmat , sc -> twe_cmd , sc -> twe_cmdmap ) ; } if ( sc -> twe_immediate != NULL ) { bus_dmamap_unload ( sc -> twe_immediate_dmat , sc -> twe_immediate_map ) ; bus_dmamem_free ( sc -> twe_immediate_dmat , sc -> twe_immediate , sc -> twe_immediate_map ) ; } if ( sc -> twe_immediate_dmat ) bus_dma_tag_destroy ( sc -> twe_immediate_dmat ) ; if ( sc -> twe_buffer_dmat ) bus_dma_tag_destroy ( sc -> twe_buffer_dmat ) ; if ( sc -> twe_intr ) bus_teardown_intr ( sc -> twe_dev , sc -> twe_irq , sc -> twe_intr ) ; if ( sc -> twe_irq != NULL ) bus_release_resource ( sc -> twe_dev , SYS_RES_IRQ , 0 , sc -> twe_irq ) ; if ( sc -> twe_parent_dmat ) bus_dma_tag_destroy ( sc -> twe_parent_dmat ) ; if ( sc -> twe_io != NULL ) bus_release_resource ( sc -> twe_dev , SYS_RES_IOPORT , TWE_IO_CONFIG_REG , sc -> twe_io ) ; if ( sc -> twe_dev_t != ( struct cdev * ) NULL ) destroy_dev ( sc -> twe_dev_t ) ; sx_destroy ( & sc -> twe_config_lock ) ; mtx_destroy ( & sc -> twe_io_lock ) ; }
Free all of the resources associated with (sc).
Free all of the resources associated with ( sc ) .
/* throw away any command buffers */ /* destroy the data-transfer DMA tag */ /* disconnect the interrupt handler */ /* destroy the parent DMA tag */ /* release the register window mapping */ /* destroy control device */