/* proxying to the parent */ static int siba_bwn_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie) { return (BUS_TEARDOWN_INTR(device_get_parent(dev), dev, irq, cookie)); }
static int siba_pcib_teardown_intr(device_t dev, device_t child, struct resource *vec, void *cookie) { return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, vec, cookie)); }
/* * Resource is useless here since ppbus devices' interrupt handlers are * multiplexed to the same resource initially allocated by ppc */ int ppc_setup_intr(device_t bus, device_t child, struct resource *r, int flags, void (*ihand)(void *), void *arg, void **cookiep) { int error; struct ppc_data *ppc = DEVTOSOFTC(bus); if (ppc->ppc_registered) { /* XXX refuse registration if DMA is in progress */ /* first, unregister the default interrupt handler */ if ((error = BUS_TEARDOWN_INTR(device_get_parent(bus), bus, ppc->res_irq, ppc->intr_cookie))) return (error); /* bus_deactivate_resource(bus, SYS_RES_IRQ, ppc->rid_irq, */ /* ppc->res_irq); */ /* DMA/FIFO operation won't be possible anymore */ ppc->ppc_registered = 0; } /* pass registration to the upper layer, ignore the incoming resource */ return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags, ihand, arg, cookiep)); }
static int envctrl_detach(device_t dev) { struct pcf_softc *sc; int rv; sc = DEVTOSOFTC(dev); if ((rv = bus_generic_detach(dev)) != 0) return (rv); if ((rv = device_delete_child(dev, sc->iicbus)) != 0) return (rv); if (sc->res_irq != 0) { BUS_TEARDOWN_INTR(device_get_parent(dev), dev, sc->res_irq, sc->intr_cookie); bus_deactivate_resource(dev, SYS_RES_IRQ, sc->rid_irq, sc->res_irq); bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, sc->res_irq); } bus_deactivate_resource(dev, SYS_RES_IOPORT, sc->rid_ioport, sc->res_ioport); bus_release_resource(dev, SYS_RES_IOPORT, sc->rid_ioport, sc->res_ioport); return (0); }
static int at91_teardown_intr(device_t dev, device_t child, struct resource *res, void *cookie) { struct at91_softc *sc = device_get_softc(dev); bus_space_write_4(sc->sc_st, sc->sc_aic_sh, IC_IDCR, 1 << rman_get_start(res)); return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, res, cookie)); }
static int ixp425_teardown_intr(device_t dev, device_t child, struct resource *res, void *cookie) { uint32_t mask, mask2; get_masks(res, &mask, &mask2); update_masks(intr_enabled &~ mask, intr_enabled2 &~ mask2); return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, res, cookie)); }
/** * omap_teardown_intr * * RETURNS: * 0 on success */ int omap_teardown_intr(device_t dev, device_t child, struct resource *res, void *cookie) { unsigned int i; /* Mask (disable) all the interrupts in the range ... will probably be only one */ for (i = rman_get_start(res); (i < NIRQ) && (i <= rman_get_end(res)); i++) { arm_mask_irq(i); } return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, res, cookie)); }
int ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie) { if (ata_legacy(dev)) { return BUS_TEARDOWN_INTR(device_get_parent(dev), child, irq, cookie); } else { struct ata_pci_controller *controller = device_get_softc(dev); int unit = ((struct ata_channel *)device_get_softc(child))->unit; controller->interrupt[unit].function = NULL; controller->interrupt[unit].argument = NULL; return 0; } }
static int sbus_teardown_intr(device_t dev, device_t child, struct resource *vec, void *cookie) { struct sbus_clr *scl; int error; scl = (struct sbus_clr *)cookie; error = BUS_TEARDOWN_INTR(device_get_parent(dev), child, vec, scl->scl_cookie); /* * Don't disable the interrupt for now, so that stray interupts get * detected... */ if (error != 0) free(scl, M_DEVBUF); return (error); }
int puc_bus_teardown_intr(device_t dev, device_t child, struct resource *res, void *cookie) { struct puc_port *port; struct puc_softc *sc; device_t originator; int i; sc = device_get_softc(dev); /* Get our immediate child. */ originator = child; while (child != NULL && device_get_parent(child) != dev) child = device_get_parent(child); if (child == NULL) return (EINVAL); port = device_get_ivars(child); KASSERT(port != NULL, ("%s %d", __func__, __LINE__)); if (res != port->p_ires) return (EINVAL); if (rman_get_device(port->p_ires) != originator) return (ENXIO); if (!port->p_hasintr) return (BUS_TEARDOWN_INTR(device_get_parent(dev), originator, sc->sc_ires, cookie)); if (cookie != port) return (EINVAL); port->p_hasintr = 0; port->p_iharg = NULL; for (i = 0; i < PUC_ISRCCNT; i++) port->p_ihsrc[i] = NULL; return (0); }
int ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie) { struct ata_pci_controller *controller = device_get_softc(dev); if (controller->legacy) { return BUS_TEARDOWN_INTR(device_get_parent(dev), child, irq, cookie); } else { struct ata_pci_controller *controller = device_get_softc(dev); int unit; if (device_get_devclass(child) == ata_devclass) unit = ((struct ata_channel *)device_get_softc(child))->unit; else unit = ATA_PCI_MAX_CH - 1; controller->interrupt[unit].function = NULL; controller->interrupt[unit].argument = NULL; return 0; } }
/* * When no underlying device has a registered interrupt, register the ppc * layer one */ int ppc_teardown_intr(device_t bus, device_t child, struct resource *r, void *ih) { int error; struct ppc_data *ppc = DEVTOSOFTC(bus); device_t parent = device_get_parent(bus); /* pass unregistration to the upper layer */ if ((error = BUS_TEARDOWN_INTR(parent, child, r, ih))) return (error); /* default to the tty mask for registration */ /* XXX */ if (ppc->ppc_irq && !(error = BUS_SETUP_INTR(parent, bus, ppc->res_irq, INTR_TYPE_TTY, ppcintr, bus, &ppc->intr_cookie))) { /* remember the ppcintr is registered */ ppc->ppc_registered = 1; } return (error); }
/* * Detach - reverse anything done by attach. */ static int xenpci_detach(device_t dev) { struct xenpci_softc *scp = device_get_softc(dev); device_t parent = device_get_parent(dev); /* * Take our interrupt handler out of the list of handlers * that can handle this irq. */ if (scp->intr_cookie != NULL) { if (BUS_TEARDOWN_INTR(parent, dev, scp->res_irq, scp->intr_cookie) != 0) printf("intr teardown failed.. continuing\n"); scp->intr_cookie = NULL; } /* * Deallocate any system resources we may have * allocated on behalf of this driver. */ return (xenpci_deallocate_resources(dev)); }
static int gt_teardown_intr(device_t dev, device_t child, struct resource *res, void *cookie) { return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, res, cookie)); }
static int ohci_pci_attach(device_t self) { device_t parent = device_get_parent(self); ohci_softc_t *sc = device_get_softc(self); int err; int rid; struct resource *io_res, *irq_res; void *ih; int intr; /* For the moment, put in a message stating what is wrong */ intr = pci_read_config(self, PCIR_INTLINE, 1); if (intr == 0 || intr == 255) { device_printf(self, "Invalid irq %d\n", intr); device_printf(self, "Please switch on USB support and switch PNP-OS to 'No' in BIOS\n"); return ENXIO; } /* XXX where does it say so in the spec? */ sc->sc_bus.usbrev = USBREV_1_0; rid = PCI_CBMEM; io_res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); if (!io_res) { device_printf(self, "could not map memory\n"); return ENXIO; } sc->iot = rman_get_bustag(io_res); sc->ioh = rman_get_bushandle(io_res); rid = 0; irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE); if (irq_res == NULL) { device_printf(self, "could not allocate irq\n"); err = ENOMEM; goto bad1; } sc->sc_bus.bdev = device_add_child(self, "usb", -1); if (!sc->sc_bus.bdev) { device_printf(self, "could not add USB device\n"); err = ENOMEM; goto bad2; } device_set_ivars(sc->sc_bus.bdev, sc); switch (pci_get_devid(self)) { case PCI_OHCI_DEVICEID_ALADDIN_V: device_set_desc(sc->sc_bus.bdev, ohci_device_aladdin_v); sprintf(sc->sc_vendor, "AcerLabs"); break; case PCI_OHCI_DEVICEID_AMD756: device_set_desc(sc->sc_bus.bdev, ohci_device_amd756); sprintf(sc->sc_vendor, "AMD"); break; case PCI_OHCI_DEVICEID_FIRELINK: device_set_desc(sc->sc_bus.bdev, ohci_device_firelink); sprintf(sc->sc_vendor, "OPTi"); break; case PCI_OHCI_DEVICEID_NEC: device_set_desc(sc->sc_bus.bdev, ohci_device_nec); sprintf(sc->sc_vendor, "NEC"); break; case PCI_OHCI_DEVICEID_USB0670: device_set_desc(sc->sc_bus.bdev, ohci_device_usb0670); sprintf(sc->sc_vendor, "CMDTECH"); break; case PCI_OHCI_DEVICEID_USB0673: device_set_desc(sc->sc_bus.bdev, ohci_device_usb0673); sprintf(sc->sc_vendor, "CMDTECH"); break; default: if (bootverbose) device_printf(self, "(New OHCI DeviceId=0x%08x)\n", pci_get_devid(self)); device_set_desc(sc->sc_bus.bdev, ohci_device_generic); sprintf(sc->sc_vendor, "(unknown)"); } err = BUS_SETUP_INTR(parent, self, irq_res, INTR_TYPE_BIO, (driver_intr_t *) ohci_intr, sc, &ih); if (err) { device_printf(self, "could not setup irq, %d\n", err); goto bad3; } err = ohci_init(sc); if (!err) err = device_probe_and_attach(sc->sc_bus.bdev); if (err) { device_printf(self, "USB init failed\n"); err = EIO; goto bad4; } return 0; bad4: /* disable interrupts that might have been switched on * in ohci_init */ bus_space_write_4(sc->iot, sc->ioh, OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); err = BUS_TEARDOWN_INTR(parent, self, irq_res, ih); if (err) /* XXX or should we panic? */ device_printf(self, "could not tear down irq, %d\n", err); bad3: device_delete_child(self, sc->sc_bus.bdev); bad2: bus_release_resource(self, SYS_RES_IOPORT, 0, irq_res); bad1: bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, io_res); return err; }
int isa_teardown_intr(device_t bus, device_t child, struct resource *r, void *cookie) { return (BUS_TEARDOWN_INTR(device_get_parent(bus), child, r, cookie)); }