Module Name: src Committed By: jmcneill Date: Fri Sep 12 20:52:52 UTC 2014
Modified Files: src/sys/arch/arm/broadcom: bcm2835_dmac.c Log Message: improve error handling in bcm_dmac_alloc and disestablish the irq handler in bcm_dmac_free To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/broadcom/bcm2835_dmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/broadcom/bcm2835_dmac.c diff -u src/sys/arch/arm/broadcom/bcm2835_dmac.c:1.6 src/sys/arch/arm/broadcom/bcm2835_dmac.c:1.7 --- src/sys/arch/arm/broadcom/bcm2835_dmac.c:1.6 Fri Sep 12 19:33:45 2014 +++ src/sys/arch/arm/broadcom/bcm2835_dmac.c Fri Sep 12 20:52:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: bcm2835_dmac.c,v 1.6 2014/09/12 19:33:45 jakllsch Exp $ */ +/* $NetBSD: bcm2835_dmac.c,v 1.7 2014/09/12 20:52:52 jmcneill Exp $ */ /*- * Copyright (c) 2014 Jared D. McNeill <jmcne...@invisible.ca> @@ -29,7 +29,7 @@ #include "opt_ddb.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bcm2835_dmac.c,v 1.6 2014/09/12 19:33:45 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcm2835_dmac.c,v 1.7 2014/09/12 20:52:52 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -208,12 +208,17 @@ bcm_dmac_alloc(enum bcm_dmac_type type, } mutex_exit(&sc->sc_lock); + if (ch == NULL) + return NULL; + + KASSERT(ch->ch_ih == NULL); ch->ch_ih = bcm2835_intr_establish(BCM2835_INT_DMA0 + ch->ch_index, ipl, bcm_dmac_intr, ch); if (ch->ch_ih == NULL) { aprint_error_dev(sc->sc_dev, "failed to establish interrupt for DMA%d\n", ch->ch_index); - sc->sc_channelmask &= ~__BIT(index); + ch->ch_callback = NULL; + ch->ch_callbackarg = NULL; } return ch; @@ -234,6 +239,8 @@ bcm_dmac_free(struct bcm_dmac_channel *c DMAC_WRITE(sc, DMAC_CS(ch->ch_index), val); mutex_enter(&sc->sc_lock); + intr_disestablish(ch->ch_ih); + ch->ch_ih = NULL; ch->ch_callback = NULL; ch->ch_callbackarg = NULL; mutex_exit(&sc->sc_lock);