FreeBSD/sys/dev/bhnd/bhndb/bhndb_subr.c
/**
 * Deallocate the given bridge resource structure and any associated resources.
 * 
 * @param br Resource state to be deallocated.
 */
Deallocate the given bridge resource structure and any associated resources.

@param br Resource state to be deallocated.
Deallocate the given bridge resource structure and any associated resources . @param br Resource state to be deallocated .
void
bhndb_free_resources(struct bhndb_resources *br)
{
	struct bhndb_region	*region, *r_next;
	struct bhndb_dw_alloc	*dwa;
	struct bhndb_dw_rentry	*dwr, *dwr_next;
	if (__builtin_popcount(br->dwa_freelist) != br->dwa_count) {
		device_printf(br->dev, "leaked %llu dynamic register regions\n",
		    (unsigned long long) br->dwa_count - br->dwa_freelist);
	}
	bus_release_resources(br->parent_dev, br->res_spec, br->res);
	for (size_t i = 0; i < br->dwa_count; i++) {
		dwa = &br->dw_alloc[i];
		LIST_FOREACH_SAFE(dwr, &dwa->refs, dw_link, dwr_next) {
			LIST_REMOVE(dwr, dw_link);
			free(dwr, M_BHND);
		}
	}
	STAILQ_FOREACH_SAFE(region, &br->bus_regions, link, r_next) {
		STAILQ_REMOVE(&br->bus_regions, region, bhndb_region, link);
		free(region, M_BHND);
	}
	rman_fini(&br->ht_mem_rman);
	rman_fini(&br->br_mem_rman);
	free(br->res, M_BHND);
	free(br->res_spec, M_BHND);
	free(br->dw_alloc, M_BHND);
}
void bhndb_free_resources ( struct bhndb_resources * br ) { struct bhndb_region * region , * r_next ; struct bhndb_dw_alloc * dwa ; struct bhndb_dw_rentry * dwr , * dwr_next ; if ( __builtin_popcount ( br -> dwa_freelist ) != br -> dwa_count ) { device_printf ( br -> dev , " \n " , ( unsigned long long ) br -> dwa_count - br -> dwa_freelist ) ; } bus_release_resources ( br -> parent_dev , br -> res_spec , br -> res ) ; for ( size_t i = 0 ; i < br -> dwa_count ; i ++ ) { dwa = & br -> dw_alloc [ i ] ; LIST_FOREACH_SAFE ( dwr , & dwa -> refs , dw_link , dwr_next ) { LIST_REMOVE ( dwr , dw_link ) ; free ( dwr , M_BHND ) ; } } STAILQ_FOREACH_SAFE ( region , & br -> bus_regions , link , r_next ) { STAILQ_REMOVE ( & br -> bus_regions , region , bhndb_region , link ) ; free ( region , M_BHND ) ; } rman_fini ( & br -> ht_mem_rman ) ; rman_fini ( & br -> br_mem_rman ) ; free ( br -> res , M_BHND ) ; free ( br -> res_spec , M_BHND ) ; free ( br -> dw_alloc , M_BHND ) ; }
Deallocate the given bridge resource structure and any associated resources.
Deallocate the given bridge resource structure and any associated resources .
/* No window regions may still be held */ /* Release resources allocated through our parent. */ /* Clean up resource reservations */ /* Release bus regions */ /* Release our resource managers */ /* Free backing resource state structures */