FreeBSD/sys/dev/vxge/vxge.c
/*
 * vxge_free_resources
 * Undo what-all we did during load/attach
 */
vxge_free_resources
Undo what-all we did during load/attach
vxge_free_resources Undo what - all we did during load / attach
void
vxge_free_resources(device_t ndev, vxge_free_resources_e vxge_free_resource)
{
	int i;
	vxge_dev_t *vdev;
	vdev = (vxge_dev_t *) device_get_softc(ndev);
	switch (vxge_free_resource) {
	case VXGE_FREE_ALL:
		for (i = 0; i < vdev->intr_count; i++) {
			bus_teardown_intr(ndev,
			    vdev->config.isr_info[i].irq_res,
			    vdev->config.isr_info[i].irq_handle);
		}
	case VXGE_FREE_INTERFACE:
		ether_ifdetach(vdev->ifp);
		bus_generic_detach(ndev);
		if_free(vdev->ifp);
	case VXGE_FREE_MEDIA:
		ifmedia_removeall(&vdev->media);
	case VXGE_FREE_MUTEX:
		vxge_mutex_destroy(vdev);
	case VXGE_FREE_VPATH:
		vxge_mem_free(vdev->vpaths,
		    vdev->no_of_vpath * sizeof(vxge_vpath_t));
	case VXGE_FREE_TERMINATE_DEVICE:
		if (vdev->devh != NULL) {
			vxge_hal_device_private_set(vdev->devh, 0);
			vxge_hal_device_terminate(vdev->devh);
		}
	case VXGE_FREE_ISR_RESOURCE:
		vxge_free_isr_resources(vdev);
	case VXGE_FREE_BAR2:
		vxge_free_bar_resources(vdev, 2);
	case VXGE_FREE_BAR1:
		vxge_free_bar_resources(vdev, 1);
	case VXGE_FREE_BAR0:
		vxge_free_bar_resources(vdev, 0);
	case VXGE_FREE_PCI_INFO:
		vxge_mem_free(vdev->pdev, sizeof(vxge_pci_info_t));
	case VXGE_FREE_DEVICE_CONFIG:
		vxge_mem_free(vdev->device_config,
		    sizeof(vxge_hal_device_config_t));
	case VXGE_DISABLE_PCI_BUSMASTER:
		pci_disable_busmaster(ndev);
	case VXGE_FREE_TERMINATE_DRIVER:
		if (vxge_dev_ref_count) {
			--vxge_dev_ref_count;
			if (0 == vxge_dev_ref_count)
				vxge_hal_driver_terminate();
		}
	default:
	case VXGE_FREE_NONE:
		break;
	}
}
void vxge_free_resources ( device_t ndev , vxge_free_resources_e vxge_free_resource ) { int i ; vxge_dev_t * vdev ; vdev = ( vxge_dev_t * ) device_get_softc ( ndev ) ; switch ( vxge_free_resource ) { case VXGE_FREE_ALL : for ( i = 0 ; i < vdev -> intr_count ; i ++ ) { bus_teardown_intr ( ndev , vdev -> config . isr_info [ i ] . irq_res , vdev -> config . isr_info [ i ] . irq_handle ) ; } case VXGE_FREE_INTERFACE : ether_ifdetach ( vdev -> ifp ) ; bus_generic_detach ( ndev ) ; if_free ( vdev -> ifp ) ; case VXGE_FREE_MEDIA : ifmedia_removeall ( & vdev -> media ) ; case VXGE_FREE_MUTEX : vxge_mutex_destroy ( vdev ) ; case VXGE_FREE_VPATH : vxge_mem_free ( vdev -> vpaths , vdev -> no_of_vpath * sizeof ( vxge_vpath_t ) ) ; case VXGE_FREE_TERMINATE_DEVICE : if ( vdev -> devh != NULL ) { vxge_hal_device_private_set ( vdev -> devh , 0 ) ; vxge_hal_device_terminate ( vdev -> devh ) ; } case VXGE_FREE_ISR_RESOURCE : vxge_free_isr_resources ( vdev ) ; case VXGE_FREE_BAR2 : vxge_free_bar_resources ( vdev , 2 ) ; case VXGE_FREE_BAR1 : vxge_free_bar_resources ( vdev , 1 ) ; case VXGE_FREE_BAR0 : vxge_free_bar_resources ( vdev , 0 ) ; case VXGE_FREE_PCI_INFO : vxge_mem_free ( vdev -> pdev , sizeof ( vxge_pci_info_t ) ) ; case VXGE_FREE_DEVICE_CONFIG : vxge_mem_free ( vdev -> device_config , sizeof ( vxge_hal_device_config_t ) ) ; case VXGE_DISABLE_PCI_BUSMASTER : pci_disable_busmaster ( ndev ) ; case VXGE_FREE_TERMINATE_DRIVER : if ( vxge_dev_ref_count ) { -- vxge_dev_ref_count ; if ( 0 == vxge_dev_ref_count ) vxge_hal_driver_terminate ( ) ; } default : case VXGE_FREE_NONE : break ; } }
vxge_free_resources
 Undo what-all we did during load/attach
vxge_free_resources Undo what - all we did during load / attach
/* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* FALLTHROUGH */ /* NOTREACHED */