Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-spi
[oweals/u-boot.git] / drivers / dma / bcm6348-iudma.c
index 1d3c192cfe5bb983bcd49168d3f1b558c20bac5f..d99460f2fb2bc965fb4df4915f47332f42cfaa84 100644 (file)
 
 #include <common.h>
 #include <clk.h>
+#include <cpu_func.h>
 #include <dm.h>
 #include <dma-uclass.h>
+#include <malloc.h>
 #include <memalign.h>
 #include <reset.h>
 #include <asm/io.h>
@@ -324,6 +326,9 @@ static int bcm6348_iudma_receive(struct dma *dma, void **dst, void *metadata)
        struct bcm6348_dma_desc *dma_desc = dma_desc = ch_priv->dma_ring;
        int ret;
 
+       if (!ch_priv->running)
+               return -EINVAL;
+
        /* get dma ring descriptor address */
        dma_desc += ch_priv->desc_id;
 
@@ -369,6 +374,9 @@ static int bcm6348_iudma_send(struct dma *dma, void *src, size_t len,
        struct bcm6348_dma_desc *dma_desc;
        uint16_t status;
 
+       if (!ch_priv->running)
+                return -EINVAL;
+
        /* flush cache */
        bcm6348_iudma_fdc(src, len);