FreeBSD/sys/dev/pci/pci.c
/* free pcicfgregs structure and all depending data structures */
free pcicfgregs structure and all depending data structures
free pcicfgregs structure and all depending data structures
int
pci_freecfg(struct pci_devinfo *dinfo)
{
	struct devlist *devlist_head;
	struct pci_map *pm, *next;
	int i;
	devlist_head = &pci_devq;
	if (dinfo->cfg.vpd.vpd_reg) {
		free(dinfo->cfg.vpd.vpd_ident, M_DEVBUF);
		for (i = 0; i < dinfo->cfg.vpd.vpd_rocnt; i++)
			free(dinfo->cfg.vpd.vpd_ros[i].value, M_DEVBUF);
		free(dinfo->cfg.vpd.vpd_ros, M_DEVBUF);
		for (i = 0; i < dinfo->cfg.vpd.vpd_wcnt; i++)
			free(dinfo->cfg.vpd.vpd_w[i].value, M_DEVBUF);
		free(dinfo->cfg.vpd.vpd_w, M_DEVBUF);
	}
	STAILQ_FOREACH_SAFE(pm, &dinfo->cfg.maps, pm_link, next) {
		free(pm, M_DEVBUF);
	}
	STAILQ_REMOVE(devlist_head, dinfo, pci_devinfo, pci_links);
	free(dinfo, M_DEVBUF);
	pci_generation++;
	pci_numdevs--;
	return (0);
}
int pci_freecfg ( struct pci_devinfo * dinfo ) { struct devlist * devlist_head ; struct pci_map * pm , * next ; int i ; devlist_head = & pci_devq ; if ( dinfo -> cfg . vpd . vpd_reg ) { free ( dinfo -> cfg . vpd . vpd_ident , M_DEVBUF ) ; for ( i = 0 ; i < dinfo -> cfg . vpd . vpd_rocnt ; i ++ ) free ( dinfo -> cfg . vpd . vpd_ros [ i ] . value , M_DEVBUF ) ; free ( dinfo -> cfg . vpd . vpd_ros , M_DEVBUF ) ; for ( i = 0 ; i < dinfo -> cfg . vpd . vpd_wcnt ; i ++ ) free ( dinfo -> cfg . vpd . vpd_w [ i ] . value , M_DEVBUF ) ; free ( dinfo -> cfg . vpd . vpd_w , M_DEVBUF ) ; } STAILQ_FOREACH_SAFE ( pm , & dinfo -> cfg . maps , pm_link , next ) { free ( pm , M_DEVBUF ) ; } STAILQ_REMOVE ( devlist_head , dinfo , pci_devinfo , pci_links ) ; free ( dinfo , M_DEVBUF ) ; pci_generation ++ ; pci_numdevs -- ; return ( 0 ) ; }
free pcicfgregs structure and all depending data structures
free pcicfgregs structure and all depending data structures
/* increment the generation count */ /* we're losing one device */