static void acpicpu_evcnt_detach(device_t self) { struct acpicpu_softc *sc = device_private(self); struct acpicpu_cstate *cs; struct acpicpu_pstate *ps; struct acpicpu_tstate *ts; uint32_t i; for (i = 0; i < __arraycount(sc->sc_cstate); i++) { cs = &sc->sc_cstate[i]; if (cs->cs_method != 0) evcnt_detach(&cs->cs_evcnt); } for (i = 0; i < sc->sc_pstate_count; i++) { ps = &sc->sc_pstate[i]; if (ps->ps_freq != 0) evcnt_detach(&ps->ps_evcnt); } for (i = 0; i < sc->sc_tstate_count; i++) { ts = &sc->sc_tstate[i]; if (ts->ts_percent != 0) evcnt_detach(&ts->ts_evcnt); } }
int mididetach(device_t self, int flags) { struct midi_softc *sc = device_private(self); int maj, mn; DPRINTFN(2,("%s: sc=%p flags=%d\n", __func__, sc, flags)); pmf_device_deregister(self); mutex_enter(sc->lock); sc->dying = 1; cv_broadcast(&sc->wchan); cv_broadcast(&sc->rchan); mutex_exit(sc->lock); /* locate the major number */ maj = cdevsw_lookup_major(&midi_cdevsw); /* * Nuke the vnodes for any open instances (calls close). * Will wait until any activity on the device nodes has ceased. * * XXXAD NOT YET. * * XXXAD NEED TO PREVENT NEW REFERENCES THROUGH AUDIO_ENTER(). */ mn = device_unit(self); vdevgone(maj, mn, mn, VCHR); if (!(sc->props & MIDI_PROP_NO_OUTPUT)) { evcnt_detach(&sc->xmt.bytesDiscarded); evcnt_detach(&sc->xmt.incompleteMessages); } if (sc->props & MIDI_PROP_CAN_INPUT) { evcnt_detach(&sc->rcv.bytesDiscarded); evcnt_detach(&sc->rcv.incompleteMessages); } if (sc->sih != NULL) { softint_disestablish(sc->sih); sc->sih = NULL; } cv_destroy(&sc->wchan); cv_destroy(&sc->rchan); return (0); }
static void necpb_intr_disestablish(pci_chipset_tag_t pc, void *cookie) { struct necpb_intrhand *n, *p, *q; uint32_t mask; n = cookie; q = NULL; p = necpb_inttbl[n->ih_intn]; while (p != n) { if (p == NULL) panic("%s: broken intr table", __func__); q = p; p = p->ih_next; } if (q == NULL) { necpb_inttbl[n->ih_intn] = n->ih_next; if (n->ih_next == NULL) { mask = in32(RD94_SYS_PCI_INTMASK); mask &= ~(1 << n->ih_intn); out32(RD94_SYS_PCI_INTMASK, mask); } } else q->ih_next = n->ih_next; evcnt_detach(&n->ih_evcnt); free(n, M_DEVBUF); }
static void pic_percpu_evcnt_deattach(void *v0, void *v1, struct cpu_info *ci) { struct pic_percpu * const pcpu = v0; struct intrsource * const is = v1; KASSERT(pcpu->pcpu_magic == PICPERCPU_MAGIC); evcnt_detach(&pcpu->pcpu_evs[is->is_irq]); }
int irq_release(int irq, irqhandler_t *handler) { irqhandler_t *irqhand; irqhandler_t **prehand; /* * IRQ_INSTRUCT indicates that we should get the irq number * from the irq structure */ if (irq == IRQ_INSTRUCT) irq = handler->ih_num; /* Make sure the irq number is valid */ if (irq < 0 || irq >= NIRQS) return(-1); /* Locate the handler */ prehand = &irqhandlers[irq]; irqhand = *prehand; while (irqhand && handler != irqhand) { prehand = &irqhand->ih_next; irqhand = *prehand; } /* Remove the handler if located */ if (irqhand) *prehand = irqhand->ih_next; else return(-1); /* The handler has been removed from the chain so mark it as inactive */ irqhand->ih_flags &= ~IRQ_FLAG_ACTIVE; /* Make sure the head of the handler list is active */ if (irqhandlers[irq]) irqhandlers[irq]->ih_flags |= IRQ_FLAG_ACTIVE; evcnt_detach(&irqhand->ih_ev); irq_calculatemasks(); /* * Disable the appropriate mask bit if there are no handlers left for * this IRQ. */ if (irqhandlers[irq] == NULL) disable_irq(irq); set_spl_masks(); return(0); }
void jazzio_intr_disestablish(int intr) { struct jazzio_intrhand *jirp; jazzio_int_mask &= ~(1 << intr); jirp = &jazzio_intrtab[intr]; jirp->ih_func = jazzio_no_handler; jirp->ih_arg = NULL; evcnt_detach(&jirp->ih_evcnt); (*jazzio_conf->jc_set_iointr_mask)(jazzio_int_mask); }
/* * Deregister an interrupt handler. */ void intr_disestablish(void *arg) { struct intrhand * const ih = arg; const int virq = ih->ih_virq; struct intr_source * const is = &intrsources[virq]; struct intrhand **p, **q; int maxipl = IPL_NONE; if (!PIC_VIRQ_LEGAL_P(virq)) panic("intr_disestablish: bogus virq %d", virq); /* * Remove the handler from the chain. * This is O(n^2), too. */ for (p = &is->is_hand, q = NULL; (*p) != NULL; p = &(*p)->ih_next) { struct intrhand * const tmp_ih = *p; if (tmp_ih == ih) { q = p; } else { maxipl = max(maxipl, tmp_ih->ih_ipl); } } if (q) *q = ih->ih_next; else panic("intr_disestablish: handler not registered"); kmem_intr_free((void *)ih, sizeof(*ih)); /* * Reset the IPL for this source now that we've removed a handler. */ is->is_ipl = maxipl; intr_calculatemasks(); if (is->is_hand == NULL) { is->is_type = IST_NONE; evcnt_detach(&is->is_ev); /* * Make the virutal IRQ available again. */ virq_map[virq] = 0; virq_mask |= PIC_VIRQ_TO_MASK(virq); } }
void vmetwo_intr_disestablish(void *csc, int lvl, int vec, int last, struct evcnt *evcnt) { struct vmetwo_softc *sc = csc; u_int32_t reg; int iloffset, ilshift; int bitoff; int s; s = splhigh(); #if NVMETWO > 0 /* * Sort out interrupts generated locally by the VMEChip2 from * those generated by VMEbus devices... */ if (vec >= VME2_VECTOR_LOCAL_MIN && vec <= VME2_VECTOR_LOCAL_MAX) { #endif /* * Interrupt enable/clear bit offset is 0x08 - 0x1f */ bitoff = vec - VME2_VECTOR_BASE; vme_two_handlers[vec - VME2_VECTOR_LOCAL_MIN].isr_hand = NULL; last = 1; /* Force the interrupt to be cleared */ #if NVMETWO > 0 } else { /* * Interrupts originating from the VMEbus are * controlled by an offset of 0x00 - 0x07 */ bitoff = lvl - 1; } #endif /* * Do we need to tell the VMEChip2 to block the interrupt? * (This is always true for locally-generated interrupts, but only * needs doing once when the last VMEbus handler for any given level * has been unhooked.) */ if (last) { iloffset = VME2_ILOFFSET_FROM_VECTOR(bitoff) + VME2LCSR_INTERRUPT_LEVEL_BASE; ilshift = VME2_ILSHIFT_FROM_VECTOR(bitoff); /* Disable it. */ reg = vme2_lcsr_read(sc, VME2LCSR_LOCAL_INTERRUPT_ENABLE); reg &= ~VME2_LOCAL_INTERRUPT(bitoff); vme2_lcsr_write(sc, VME2LCSR_LOCAL_INTERRUPT_ENABLE, reg); /* Set the interrupt's level to zero */ reg = vme2_lcsr_read(sc, iloffset); reg &= ~(VME2_INTERRUPT_LEVEL_MASK << ilshift); vme2_lcsr_write(sc, iloffset, reg); /* Clear it */ vme2_lcsr_write(sc, VME2LCSR_LOCAL_INTERRUPT_CLEAR, VME2_LOCAL_INTERRUPT(vec)); if (evcnt) evcnt_detach(evcnt); } /* Un-hook it */ (*sc->sc_isrunlink)(sc->sc_isrcookie, vec); splx(s); }