dmaengine: imx-sdma: pass ->dev to dma_alloc_coherent() API
authorAndy Duan <fugang.duan@nxp.com>
Fri, 11 Jan 2019 14:29:49 +0000 (14:29 +0000)
committerVinod Koul <vkoul@kernel.org>
Sun, 20 Jan 2019 10:55:31 +0000 (16:25 +0530)
Pass ->dev to dma_alloc_coherent() API. We need this
because dma_alloc_coherent() makes use of dev parameter
and receiving NULL will result in a crash.

Signed-off-by: Andy Duan <fugang.duan@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Robin Gong <yibin.gong@nxp.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/imx-sdma.c

index 015c17a3b826c169e0224fcc3bbd673d3a92289b..af14a8d6efa8855d36cc9a727064f1f3919495eb 100644 (file)
@@ -678,7 +678,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
        int ret;
        unsigned long flags;
 
-       buf_virt = dma_alloc_coherent(NULL, size, &buf_phys, GFP_KERNEL);
+       buf_virt = dma_alloc_coherent(sdma->dev, size, &buf_phys, GFP_KERNEL);
        if (!buf_virt) {
                return -ENOMEM;
        }
@@ -697,7 +697,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
 
        spin_unlock_irqrestore(&sdma->channel_0_lock, flags);
 
-       dma_free_coherent(NULL, size, buf_virt, buf_phys);
+       dma_free_coherent(sdma->dev, size, buf_virt, buf_phys);
 
        return ret;
 }
@@ -1189,7 +1189,7 @@ static int sdma_request_channel0(struct sdma_engine *sdma)
 {
        int ret = -EBUSY;
 
-       sdma->bd0 = dma_zalloc_coherent(NULL, PAGE_SIZE, &sdma->bd0_phys,
+       sdma->bd0 = dma_zalloc_coherent(sdma->dev, PAGE_SIZE, &sdma->bd0_phys,
                                        GFP_NOWAIT);
        if (!sdma->bd0) {
                ret = -ENOMEM;
@@ -1212,8 +1212,8 @@ static int sdma_alloc_bd(struct sdma_desc *desc)
        u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
        int ret = 0;
 
-       desc->bd = dma_zalloc_coherent(NULL, bd_size, &desc->bd_phys,
-                                       GFP_NOWAIT);
+       desc->bd = dma_zalloc_coherent(desc->sdmac->sdma->dev, bd_size,
+                                      &desc->bd_phys, GFP_NOWAIT);
        if (!desc->bd) {
                ret = -ENOMEM;
                goto out;
@@ -1226,7 +1226,8 @@ static void sdma_free_bd(struct sdma_desc *desc)
 {
        u32 bd_size = desc->num_bd * sizeof(struct sdma_buffer_descriptor);
 
-       dma_free_coherent(NULL, bd_size, desc->bd, desc->bd_phys);
+       dma_free_coherent(desc->sdmac->sdma->dev, bd_size, desc->bd,
+                         desc->bd_phys);
 }
 
 static void sdma_desc_free(struct virt_dma_desc *vd)
@@ -1849,7 +1850,7 @@ static int sdma_init(struct sdma_engine *sdma)
        /* Be sure SDMA has not started yet */
        writel_relaxed(0, sdma->regs + SDMA_H_C0PTR);
 
-       sdma->channel_control = dma_alloc_coherent(NULL,
+       sdma->channel_control = dma_alloc_coherent(sdma->dev,
                        MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control) +
                        sizeof(struct sdma_context_data),
                        &ccb_phys, GFP_KERNEL);