dmaengine: dma_request_chan_by_mask() to handle deferred probing
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Wed, 18 Jul 2018 09:29:57 +0000 (12:29 +0300)
committerVinod Koul <vkoul@kernel.org>
Wed, 25 Jul 2018 12:34:15 +0000 (18:04 +0530)
If there are no DMA devices registered yet, return with EPROBE_DEFER
similarly to the case when requesting a slave channel.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/dmaengine.c

index 84ac38d..504420f 100644 (file)
@@ -770,8 +770,14 @@ struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask)
                return ERR_PTR(-ENODEV);
 
        chan = __dma_request_channel(mask, NULL, NULL);
-       if (!chan)
-               chan = ERR_PTR(-ENODEV);
+       if (!chan) {
+               mutex_lock(&dma_list_mutex);
+               if (list_empty(&dma_device_list))
+                       chan = ERR_PTR(-EPROBE_DEFER);
+               else
+                       chan = ERR_PTR(-ENODEV);
+               mutex_unlock(&dma_list_mutex);
+       }
 
        return chan;
 }