int
malo_cardbus_detach(struct device *self, int flags)
{
    struct malo_cardbus_softc *csc = (struct malo_cardbus_softc *)self;
    struct malo_softc *sc = &csc->sc_malo;
    cardbus_devfunc_t ct = csc->sc_ct;
    cardbus_chipset_tag_t cc = ct->ct_cc;
    cardbus_function_tag_t cf = ct->ct_cf;
    int error;

    error = malo_detach(sc);
    if (error != 0)
        return (error);

    /* unhook the interrupt handler */
    if (csc->sc_ih != NULL) {
        cardbus_intr_disestablish(cc, cf, csc->sc_ih);
        csc->sc_ih = NULL;
    }

    /* release bus space and close window */
    Cardbus_mapreg_unmap(ct, CARDBUS_BASE0_REG, sc->sc_mem1_bt,
                         sc->sc_mem1_bh, csc->sc_mapsize1);
    Cardbus_mapreg_unmap(ct, CARDBUS_BASE1_REG, sc->sc_mem2_bt,
                         sc->sc_mem2_bh, csc->sc_mapsize2);

    return (0);
}
Exemple #2
0
static int
malo_pci_detach(device_t dev)
{
	int i;
	struct malo_pci_softc *psc = device_get_softc(dev);
	struct malo_softc *sc = &psc->malo_sc;

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

	malo_detach(sc);

	bus_generic_detach(dev);

	if (psc->malo_msi == 0)
		bus_teardown_intr(dev, psc->malo_res_irq[0],
		    psc->malo_intrhand[0]);
	else {
		for (i = 0; i < MALO_MSI_MESSAGES; i++)
			bus_teardown_intr(dev, psc->malo_res_irq[i],
			    psc->malo_intrhand[i]);

		pci_release_msi(dev);
	}

	bus_release_resources(dev, psc->malo_irq_spec, psc->malo_res_irq);
	bus_dma_tag_destroy(sc->malo_dmat);
	bus_release_resources(dev, psc->malo_mem_spec, psc->malo_res_mem);

	return (0);
}
int
malo_pci_detach(device_t self, int flags)
{
	struct malo_pci_softc *psc = device_private(self);
	struct malo_softc *sc = &psc->sc_malo;

	malo_detach(sc);
	pci_intr_disestablish(psc->sc_pc, psc->sc_ih);

	return (0);
}