static int sbc_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie) { struct sbc_softc *scp = device_get_softc(dev); struct sbc_ihl *ihl = NULL; int i, ret; sbc_lock(scp); i = 0; while (i < IRQ_MAX) { if (irq == scp->irq[i]) ihl = &scp->ihl[i]; i++; } ret = 0; if (ihl == NULL) ret = EINVAL; i = 0; while ((ret == 0) && (i < INTR_MAX)) { if (cookie == &ihl->intr[i]) { ihl->intr[i] = NULL; ihl->intr_arg[i] = NULL; return 0; } else i++; } sbc_unlock(scp); return (ret > 0)? EINVAL : 0; }
static int sbc_detach(device_t dev) { struct sbc_softc *scp = device_get_softc(dev); sbc_lock(scp); device_delete_child(dev, scp->child_midi2); device_delete_child(dev, scp->child_midi1); device_delete_child(dev, scp->child_pcm); release_resource(scp); sbc_lockdestroy(scp); return bus_generic_detach(dev); }
static int sbc_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, #if __FreeBSD_version >= 700031 driver_filter_t *filter, #endif driver_intr_t *intr, void *arg, void **cookiep) { struct sbc_softc *scp = device_get_softc(dev); struct sbc_ihl *ihl = NULL; int i, ret; #if __FreeBSD_version >= 700031 if (filter != NULL) { printf("sbc.c: we cannot use a filter here\n"); return (EINVAL); } #endif sbc_lock(scp); i = 0; while (i < IRQ_MAX) { if (irq == scp->irq[i]) ihl = &scp->ihl[i]; i++; } ret = 0; if (ihl == NULL) ret = EINVAL; i = 0; while ((ret == 0) && (i < INTR_MAX)) { if (ihl->intr[i] == NULL) { ihl->intr[i] = intr; ihl->intr_arg[i] = arg; *cookiep = &ihl->intr[i]; ret = -1; } else i++; } sbc_unlock(scp); return (ret > 0)? EINVAL : 0; }
static void sb_lock(struct sb_info *sb) { sbc_lock(device_get_softc(sb->parent_dev)); }
static void ess_lock(struct ess_info *sc) { sbc_lock(device_get_softc(sc->parent_dev)); }