Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/broadcom improve error handling in bcm_dmac_all...



details:   https://anonhg.NetBSD.org/src/rev/8668999839a7
branches:  trunk
changeset: 332243:8668999839a7
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Sep 12 20:52:52 2014 +0000

description:
improve error handling in bcm_dmac_alloc and disestablish the irq handler in bcm_dmac_free

diffstat:

 sys/arch/arm/broadcom/bcm2835_dmac.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r 4dd57820bf26 -r 8668999839a7 sys/arch/arm/broadcom/bcm2835_dmac.c
--- a/sys/arch/arm/broadcom/bcm2835_dmac.c      Fri Sep 12 20:51:21 2014 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_dmac.c      Fri Sep 12 20:52:52 2014 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
        }
        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 @@
        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);



Home | Main Index | Thread Index | Old Index