Exemplo n.º 1
0
/*
 *	feunload - unload the driver and clear the table.
 */
static int
fe_pccard_detach(device_t dev)
{
    struct fe_softc *sc = device_get_softc(dev);
    struct ifnet *ifp = sc->ifp;

    FE_LOCK(sc);
    fe_stop(sc);
    FE_UNLOCK(sc);
    callout_drain(&sc->timer);
    ether_ifdetach(ifp);
    bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
    if_free(ifp);
    fe_release_resource(dev);
    mtx_destroy(&sc->lock);

    return 0;
}
Exemplo n.º 2
0
static int
bcm_spi_detach(device_t dev)
{
	struct bcm_spi_softc *sc;

	bus_generic_detach(dev);

	sc = device_get_softc(dev);
	mtx_destroy(&sc->sc_mtx);
	if (sc->sc_intrhand)
		bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand);
	if (sc->sc_irq_res)
		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);
	if (sc->sc_mem_res)
		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);

	return (0);
}
Exemplo n.º 3
0
void
sdhci_fdt_gpio_teardown(struct sdhci_fdt_gpio *gpio)
{

	if (gpio == NULL)
		return;

	if (gpio->cd_ihandler != NULL)
		bus_teardown_intr(gpio->dev, gpio->cd_ires, gpio->cd_ihandler);
	if (gpio->wp_pin != NULL)
		gpio_pin_release(gpio->wp_pin);
	if (gpio->cd_pin != NULL)
		gpio_pin_release(gpio->cd_pin);
	if (gpio->cd_ires != NULL)
		bus_release_resource(gpio->dev, SYS_RES_IRQ, 0, gpio->cd_ires);

	free(gpio, M_DEVBUF);
}
Exemplo n.º 4
0
void
stg_release_resource(device_t dev)
{
    struct stg_softc	*sc = device_get_softc(dev);

    if (sc->stg_intrhand)
        bus_teardown_intr(dev, sc->irq_res, sc->stg_intrhand);
    if (sc->port_res)
        bus_release_resource(dev, SYS_RES_IOPORT,
                             sc->port_rid, sc->port_res);
    if (sc->irq_res)
        bus_release_resource(dev, SYS_RES_IRQ,
                             sc->irq_rid, sc->irq_res);
    if (sc->mem_res)
        bus_release_resource(dev, SYS_RES_MEMORY,
                             sc->mem_rid, sc->mem_res);
    return;
}
Exemplo n.º 5
0
static int
ar71xx_ehci_detach(device_t self)
{
	struct ar71xx_ehci_softc *isc = device_get_softc(self);
	ehci_softc_t *sc = &isc->base;
	device_t bdev;
	int err;

 	if (sc->sc_bus.bdev) {
		bdev = sc->sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(self, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(self);

 	if (sc->sc_irq_res && sc->sc_intr_hdl) {
		/*
		 * only call ehci_detach() after ehci_init()
		 */
		ehci_detach(sc);

		err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);

		if (err)
			/* XXX or should we panic? */
			device_printf(self, "Could not tear down irq, %d\n",
			    err);
		sc->sc_intr_hdl = NULL;
	}

 	if (sc->sc_irq_res) {
		bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}
	if (sc->sc_io_res) {
		bus_release_resource(self, SYS_RES_MEMORY, 0,
		    sc->sc_io_res);
		sc->sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);

	return (0);
}
Exemplo n.º 6
0
static int
dotg_obio_detach(device_t dev)
{
	struct dotg_obio_softc *sc = device_get_softc(dev);
	device_t bdev;
	int err;

	if (sc->sc_dci.sc_bus.bdev) {
		bdev = sc->sc_dci.sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(dev, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	if (sc->sc_dci.sc_irq_res && sc->sc_dci.sc_intr_hdl) {
		/*
		 * only call dotg_obio_uninit() after dotg_obio_init()
		 */
		dotg_uninit(&sc->sc_dci);

		/* Stop OTG clock */
		rt305x_sysctl_set(SYSCTL_CLKCFG1, 
		    rt305x_sysctl_get(SYSCTL_CLKCFG1) & 
		    ~SYSCTL_CLKCFG1_OTG_CLK_EN);

		err = bus_teardown_intr(dev, sc->sc_dci.sc_irq_res,
		    sc->sc_dci.sc_intr_hdl);
		sc->sc_dci.sc_intr_hdl = NULL;
	}
	if (sc->sc_dci.sc_irq_res) {
		bus_release_resource(dev, SYS_RES_IRQ, 0,
		    sc->sc_dci.sc_irq_res);
		sc->sc_dci.sc_irq_res = NULL;
	}
	if (sc->sc_dci.sc_mem_res) {
		bus_release_resource(dev, SYS_RES_MEMORY, 0,
		    sc->sc_dci.sc_mem_res);
		sc->sc_dci.sc_mem_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_dci.sc_bus, NULL);

	return (0);
}
Exemplo n.º 7
0
static int
espdetach(struct esp_softc *esc)
{
	struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
	int error;

	bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq);
	error = ncr53c9x_detach(sc);
	if (error != 0)
		return (error);
	error = lsi64854_detach(esc->sc_dma);
	if (error != 0)
		return (error);
	NCR_LOCK_DESTROY(sc);
	bus_release_resource(esc->sc_dev, SYS_RES_IRQ,
	    rman_get_rid(esc->sc_irqres), esc->sc_irqres);

	return (0);
}
Exemplo n.º 8
0
static void
at91_st_deactivate(device_t dev)
{
	struct at91_st_softc *sc = timer_softc;

	if (sc->sc_intrhand)
		bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand);
	sc->sc_intrhand = NULL;

	if (sc->sc_irq_res)
		bus_release_resource(dev, SYS_RES_IRQ,
		    rman_get_rid(sc->sc_irq_res), sc->sc_irq_res);
	sc->sc_irq_res = NULL;

	if (sc->sc_mem_res)
		bus_release_resource(dev, SYS_RES_MEMORY,
		    rman_get_rid(sc->sc_mem_res), sc->sc_mem_res);
	sc->sc_mem_res = NULL;
}
Exemplo n.º 9
0
static int
ti_wdt_detach(device_t dev)
{
	struct ti_wdt_softc *sc;

	sc = device_get_softc(dev);
	if (sc->sc_ev_tag)
		EVENTHANDLER_DEREGISTER(watchdog_list, sc->sc_ev_tag);
	if (sc->sc_intr)
		bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intr);
	if (sc->sc_irq_res)
		bus_release_resource(dev, SYS_RES_IRQ,
		    rman_get_rid(sc->sc_irq_res), sc->sc_irq_res);
	if (sc->sc_mem_res)
		bus_release_resource(dev, SYS_RES_MEMORY,
		    rman_get_rid(sc->sc_mem_res),  sc->sc_mem_res);

	return (0);
}
Exemplo n.º 10
0
static int
ral_pci_detach(device_t dev)
{
	struct ral_pci_softc *psc = device_get_softc(dev);
	struct rt2560_softc *sc = &psc->u.sc_rt2560;
	
	/* check if device was removed */
	sc->sc_invalid = !bus_child_present(dev);
	
	(*psc->sc_opns->detach)(psc);

	bus_generic_detach(dev);
	bus_teardown_intr(dev, psc->irq, psc->sc_ih);
	bus_release_resource(dev, SYS_RES_IRQ, psc->irq_rid, psc->irq);

	bus_release_resource(dev, SYS_RES_MEMORY, psc->mem_rid, psc->mem);

	return 0;
}
Exemplo n.º 11
0
static void
vtpci_free_interrupt(struct vtpci_softc *sc, struct vtpci_interrupt *intr)
{
	device_t dev;

	dev = sc->vtpci_dev;

	if (intr->vti_handler != NULL) {
		bus_teardown_intr(dev, intr->vti_irq, intr->vti_handler);
		intr->vti_handler = NULL;
	}

	if (intr->vti_irq != NULL) {
		bus_release_resource(dev, SYS_RES_IRQ, intr->vti_rid,
		    intr->vti_irq);
		intr->vti_irq = NULL;
		intr->vti_rid = -1;
	}
}
Exemplo n.º 12
0
static void hpt_shutdown_vbus(PVBUS_EXT vbus_ext, int howto)
{
	PVBUS     vbus = (PVBUS)vbus_ext->vbus;
	PHBA hba;
	int i;
	
	KdPrint(("hpt_shutdown_vbus"));

	/* stop all ctl tasks and disable the worker taskqueue */
	hpt_stop_tasks(vbus_ext);
	hpt_lock_vbus(vbus_ext);
	vbus_ext->worker.ta_context = 0;

	/* flush devices */
	for (i=0; i<osm_max_targets; i++) {
		PVDEV vd = ldm_find_target(vbus, i);
		if (vd) {
			/* retry once */
			if (hpt_flush_vdev(vbus_ext, vd))
				hpt_flush_vdev(vbus_ext, vd);
		}
	}

	ldm_shutdown(vbus);
	hpt_unlock_vbus(vbus_ext);

	ldm_release_vbus(vbus);

	for (hba=vbus_ext->hba_list; hba; hba=hba->next)
		bus_teardown_intr(hba->pcidev, hba->irq_res, hba->irq_handle);

	hpt_free_mem(vbus_ext);

	while ((hba=vbus_ext->hba_list)) {
		vbus_ext->hba_list = hba->next;
		free(hba->ldm_adapter.him_handle, M_DEVBUF);
	}

	callout_drain(&vbus_ext->timer);
	mtx_destroy(&vbus_ext->lock);
	free(vbus_ext, M_DEVBUF);
	KdPrint(("hpt_shutdown_vbus done"));
}
Exemplo n.º 13
0
static int
bwi_pci_detach(device_t dev)
{
	struct bwi_pci_softc *psc = device_get_softc(dev);
	struct bwi_softc *sc = &psc->sc_sc;

	/* check if device was removed */
	sc->sc_invalid = !bus_child_present(dev);

	bwi_detach(sc);

	bus_generic_detach(dev);
	bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_irq_handle);
	bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res);

	bus_release_resource(dev, SYS_RES_MEMORY, BS_BAR, sc->sc_mem_res);

	return (0);
}
Exemplo n.º 14
0
static int
nm_pci_detach(device_t dev)
{
	int r;
	struct sc_info *sc;

	r = pcm_unregister(dev);
	if (r)
		return r;

	sc = pcm_getdevinfo(dev);
	bus_release_resource(dev, SYS_RES_MEMORY, sc->bufid, sc->buf);
	bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, sc->reg);
	bus_teardown_intr(dev, sc->irq, sc->ih);
	bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
	free(sc, M_DEVBUF);

	return 0;
}
Exemplo n.º 15
0
static void
tsec_release_intr(struct tsec_softc *sc, struct resource *ires, void *ihand,
    int irid, const char *iname)
{
	int error;

	if (ires == NULL)
		return;

	error = bus_teardown_intr(sc->dev, ires, ihand);
	if (error)
		device_printf(sc->dev, "bus_teardown_intr() failed for %s intr"
		    ", error %d\n", iname, error);

	error = bus_release_resource(sc->dev, SYS_RES_IRQ, irid, ires);
	if (error)
		device_printf(sc->dev, "bus_release_resource() failed for %s "
		    "intr, error %d\n", iname, error);
}
Exemplo n.º 16
0
static int
le_lebuffer_detach(device_t dev)
{
	struct le_lebuffer_softc *lesc;
	struct lance_softc *sc;

	lesc = device_get_softc(dev);
	sc = &lesc->sc_am7990.lsc;

	bus_teardown_intr(dev, lesc->sc_ires, lesc->sc_ih);
	am7990_detach(&lesc->sc_am7990);
	bus_release_resource(dev, SYS_RES_IRQ, lesc->sc_irid, lesc->sc_ires);
	bus_release_resource(dev, SYS_RES_MEMORY, lesc->sc_rrid, lesc->sc_rres);
	bus_release_resource(device_get_parent(dev), SYS_RES_MEMORY,
	    lesc->sc_brid, lesc->sc_bres);
	LE_LOCK_DESTROY(sc);

	return (0);
}
Exemplo n.º 17
0
static void
at91_pio_deactivate(device_t dev)
{
	struct at91_pio_softc *sc;

	sc = device_get_softc(dev);
	if (sc->intrhand)
		bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
	sc->intrhand = 0;
	bus_generic_detach(sc->dev);
	if (sc->mem_res)
		bus_release_resource(dev, SYS_RES_MEMORY,
		    rman_get_rid(sc->mem_res), sc->mem_res);
	sc->mem_res = 0;
	if (sc->irq_res)
		bus_release_resource(dev, SYS_RES_IRQ,
		    rman_get_rid(sc->irq_res), sc->irq_res);
	sc->irq_res = 0;
}
Exemplo n.º 18
0
static int
ohci_ec_detach(device_t dev)
{
	struct ec_ohci_softc *sc = device_get_softc(dev);
	device_t bdev;
	int err;

	if (sc->sc_ohci.sc_bus.bdev) {
		bdev = sc->sc_ohci.sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(dev, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	bus_space_write_4(sc->sc_ohci.sc_io_tag, sc->sc_ohci.sc_io_hdl,
	    OHCI_CONTROL, 0);

	if (sc->sc_ohci.sc_irq_res && sc->sc_ohci.sc_intr_hdl) {
		/*
		 * only call ohci_detach() after ohci_init()
		 */
		ohci_detach(&sc->sc_ohci);

		err = bus_teardown_intr(dev, sc->sc_ohci.sc_irq_res,
		    sc->sc_ohci.sc_intr_hdl);
		sc->sc_ohci.sc_intr_hdl = NULL;
	}
	if (sc->sc_ohci.sc_irq_res) {
		bus_release_resource(dev, SYS_RES_IRQ, 0,
		    sc->sc_ohci.sc_irq_res);
		sc->sc_ohci.sc_irq_res = NULL;
	}
	if (sc->sc_ohci.sc_io_res) {
		bus_release_resource(dev, SYS_RES_MEMORY, MEM_RID,
		    sc->sc_ohci.sc_io_res);
		sc->sc_ohci.sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_ohci.sc_bus, &ohci_iterate_hw_softc);

	return (0);
}
Exemplo n.º 19
0
static int
xhci_pci_detach(device_t self)
{
	struct xhci_softc *sc = device_get_softc(self);
	device_t bdev;

	if (sc->sc_bus.bdev != NULL) {
		bdev = sc->sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(self, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(self);

	if (sc->sc_io_res) {
		usb_callout_drain(&sc->sc_callout);
		xhci_halt_controller(sc);
	}

	pci_disable_busmaster(self);

	if (sc->sc_irq_res && sc->sc_intr_hdl) {
		bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
		sc->sc_intr_hdl = NULL;
	}
	if (sc->sc_irq_res) {
		if (sc->sc_irq_rid == 1)
			pci_release_msi(self);
		bus_release_resource(self, SYS_RES_IRQ, sc->sc_irq_rid,
		    sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}
	if (sc->sc_io_res) {
		bus_release_resource(self, SYS_RES_MEMORY, PCI_XHCI_CBMEM,
		    sc->sc_io_res);
		sc->sc_io_res = NULL;
	}

	xhci_uninit(sc);

	return (0);
}
Exemplo n.º 20
0
static int
octusb_octeon_detach(device_t dev)
{
    struct octusb_octeon_softc *sc = device_get_softc(dev);
    device_t bdev;
    int err;
    int nports;
    int i;

    if (sc->sc_dci.sc_bus.bdev) {
        bdev = sc->sc_dci.sc_bus.bdev;
        device_detach(bdev);
        device_delete_child(dev, bdev);
    }
    /* during module unload there are lots of children leftover */
    device_delete_children(dev);

    if (sc->sc_dci.sc_irq_res[0] && sc->sc_dci.sc_intr_hdl[0])
        /*
         * only call octusb_octeon_uninit() after octusb_octeon_init()
         */
        octusb_uninit(&sc->sc_dci);

    nports = cvmx_usb_get_num_ports();
    if (nports > OCTUSB_MAX_PORTS)
        panic("octusb: too many USB ports %d", nports);
    for (i = 0; i < nports; i++) {
        if (sc->sc_dci.sc_irq_res[0] && sc->sc_dci.sc_intr_hdl[0]) {
            err = bus_teardown_intr(dev, sc->sc_dci.sc_irq_res[i],
                                    sc->sc_dci.sc_intr_hdl[i]);
            sc->sc_dci.sc_intr_hdl[i] = NULL;
        }
        if (sc->sc_dci.sc_irq_res) {
            bus_release_resource(dev, SYS_RES_IRQ, 0,
                                 sc->sc_dci.sc_irq_res[i]);
            sc->sc_dci.sc_irq_res[i] = NULL;
        }
    }
    usb_bus_mem_free_all(&sc->sc_dci.sc_bus, NULL);

    return (0);
}
static void
vmbus_bus_exit(void)
{
    hv_vmbus_release_unattached_channels();
    hv_vmbus_disconnect();

    smp_rendezvous(NULL, hv_vmbus_synic_cleanup, NULL, NULL);

    hv_vmbus_cleanup();

    /* remove swi, bus and intr resource */
    bus_teardown_intr(vmbus_devp, intr_res, vmbus_cookiep);

    bus_release_resource(vmbus_devp, SYS_RES_IRQ, vmbus_rid, intr_res);

    swi_remove(msg_swintr);
    swi_remove(event_swintr);

    return;
}
Exemplo n.º 22
0
static int
tegra_i2c_detach(device_t dev)
{
    struct tegra_i2c_softc *sc;
    int rv;

    sc = device_get_softc(dev);
    tegra_i2c_hw_init(sc);
    if (sc->irq_h != NULL)
        bus_teardown_intr(dev, sc->irq_res, sc->irq_h);
    if (sc->irq_res != NULL)
        bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
    if (sc->mem_res != NULL)
        bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);

    LOCK_DESTROY(sc);
    if (sc->iicbus)
        rv = device_delete_child(dev, sc->iicbus);
    return (bus_generic_detach(dev));
}
Exemplo n.º 23
0
static int
tegra_gpio_detach(device_t dev)
{
	struct tegra_gpio_softc *sc;

	sc = device_get_softc(dev);

	KASSERT(mtx_initialized(&sc->sc_mtx), ("gpio mutex not initialized"));

	gpiobus_detach_bus(dev);
	if (sc->gpio_ih != NULL)
		bus_teardown_intr(dev, sc->irq_res, sc->gpio_ih);
	if (sc->irq_res != NULL)
		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
	if (sc->mem_res != NULL)
		bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
	mtx_destroy(&sc->sc_mtx);

	return(0);
}
Exemplo n.º 24
0
static void
ntb_teardown_interrupts(struct ntb_softc *ntb)
{
	struct ntb_int_info *current_int;
	int i;

	for (i = 0; i < ntb->allocated_interrupts; i++) {
		current_int = &ntb->int_info[i];
		if (current_int->tag != NULL)
			bus_teardown_intr(ntb->device, current_int->res,
			    current_int->tag);

		if (current_int->res != NULL)
			bus_release_resource(ntb->device, SYS_RES_IRQ,
			    rman_get_rid(current_int->res), current_int->res);
	}

	ntb_free_callbacks(ntb);
	pci_release_msi(ntb->device);
}
Exemplo n.º 25
0
static void
mps_pci_free(struct mps_softc *sc)
{
	if (sc->mps_parent_dmat != NULL) {
		bus_dma_tag_destroy(sc->mps_parent_dmat);
	}

	bus_teardown_intr(sc->mps_dev, sc->mps_irq[0], sc->mps_intrhand[0]);
	bus_release_resource(sc->mps_dev, SYS_RES_IRQ, sc->mps_irq_rid[0],
	    sc->mps_irq[0]);
	if (sc->mps_irq_type[0] == PCI_INTR_TYPE_MSI)
		pci_release_msi(sc->mps_dev);

	if (sc->mps_regs_resource != NULL) {
		bus_release_resource(sc->mps_dev, SYS_RES_MEMORY,
		    sc->mps_regs_rid, sc->mps_regs_resource);
	}

	return;
}
Exemplo n.º 26
0
static int
ti_gpio_detach_intr(device_t dev)
{
	int i;
	struct ti_gpio_softc *sc;

	/* Teardown our interrupt handlers. */
	sc = device_get_softc(dev);
	for (i = 0; i < MAX_GPIO_INTRS; i++) {
		if (sc->sc_irq_res[i] == NULL)
			break;

		if (sc->sc_irq_hdl[i]) {
			bus_teardown_intr(dev, sc->sc_irq_res[i],
			    sc->sc_irq_hdl[i]);
		}
	}

	return (0);
}
Exemplo n.º 27
0
static void 
ppt_teardown_msix_intr(struct pptdev *ppt, int idx)
{
	int rid;
	struct resource *res;
	void *cookie;

	rid = ppt->msix.startrid + idx;
	res = ppt->msix.res[idx];
	cookie = ppt->msix.cookie[idx];

	if (cookie != NULL) 
		bus_teardown_intr(ppt->dev, res, cookie);

	if (res != NULL) 
		bus_release_resource(ppt->dev, SYS_RES_IRQ, rid, res);

	ppt->msix.res[idx] = NULL;
	ppt->msix.cookie[idx] = NULL;
}
Exemplo n.º 28
0
/*
 * Release resources associated with device.
 */
void
ichsmb_release_resources(sc_p sc)
{
	const device_t dev = sc->dev;

	if (sc->irq_handle != NULL) {
		bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
		sc->irq_handle = NULL;
	}
	if (sc->irq_res != NULL) {
		bus_release_resource(dev,
		    SYS_RES_IRQ, sc->irq_rid, sc->irq_res);
		sc->irq_res = NULL;
	}
	if (sc->io_res != NULL) {
		bus_release_resource(dev,
		    SYS_RES_IOPORT, sc->io_rid, sc->io_res);
		sc->io_res = NULL;
	}
}
Exemplo n.º 29
0
static int
dwc_otg_detach(device_t dev)
{
	struct dwc_otg_super_softc *sc = device_get_softc(dev);
	device_t bdev;
	int err;

	if (sc->sc_otg.sc_bus.bdev) {
		bdev = sc->sc_otg.sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(dev, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) {
		/*
		 * only call dwc_otg_uninit() after dwc_otg_init()
		 */
		dwc_otg_uninit(&sc->sc_otg);

		err = bus_teardown_intr(dev, sc->sc_otg.sc_irq_res,
		    sc->sc_otg.sc_intr_hdl);
		sc->sc_otg.sc_intr_hdl = NULL;
	}
	/* free IRQ channel, if any */
	if (sc->sc_otg.sc_irq_res) {
		bus_release_resource(dev, SYS_RES_IRQ, 0,
		    sc->sc_otg.sc_irq_res);
		sc->sc_otg.sc_irq_res = NULL;
	}
	/* free memory resource, if any */
	if (sc->sc_otg.sc_io_res) {
		bus_release_resource(dev, SYS_RES_MEMORY, 0,
		    sc->sc_otg.sc_io_res);
		sc->sc_otg.sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_otg.sc_bus, NULL);

	return (0);
}
Exemplo n.º 30
0
static int
ehci_xls_detach(device_t self)
{
	ehci_softc_t *sc = device_get_softc(self);
	device_t bdev;
	int err;

 	if (sc->sc_bus.bdev) {
		bdev = sc->sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(self, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(self);

	if (sc->sc_irq_res && sc->sc_intr_hdl) {
		ehci_detach(sc);

		err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
		if (err)
			device_printf(self, "Could not tear down irq, %d\n",
			    err);
		sc->sc_intr_hdl = 0;
	}

	if (sc->sc_irq_res) {
		bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}
	if (sc->sc_io_res) {
		bus_release_resource(self, SYS_RES_MEMORY, 0,
		    sc->sc_io_res);
		sc->sc_io_res = NULL;
		sc->sc_io_tag = 0;
		sc->sc_io_hdl = 0;
	}

	usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);

	return (0);
}