From a9224c9bd73c97e2e69e9628c8bea3229b4b3022 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 16 Jan 2019 13:10:15 +0100 Subject: [PATCH] dw-dma: fail probing if setting up the controller fails If the driver is unable to release the DMA controller, abort probing. Signed-off-by: Guennadi Liakhovetski --- src/drivers/dw/dma.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/drivers/dw/dma.c b/src/drivers/dw/dma.c index 586efd56e..2b94a7549 100644 --- a/src/drivers/dw/dma.c +++ b/src/drivers/dw/dma.c @@ -1066,7 +1066,7 @@ static inline void dw_dma_chan_reload_next(struct dma *dma, int channel, dw_write(dma, DW_DMA_CHAN_EN, CHAN_ENABLE(channel)); } -static void dw_dma_setup(struct dma *dma) +static int dw_dma_setup(struct dma *dma) { struct dw_drv_plat_data *dp = dma->plat_data.drv_plat_data; int i; @@ -1083,7 +1083,7 @@ static void dw_dma_setup(struct dma *dma) if (!i) { trace_dwdma_error("dw-dma: dmac %d setup failed", dma->plat_data.id); - return; + return -EIO; } for (i = 0; i < DW_MAX_CHAN; i++) @@ -1126,6 +1126,8 @@ static void dw_dma_setup(struct dma *dma) DW_CFG_CLASS(dp->chan[i].class)); #endif } + + return 0; } static void dw_dma_process_block(struct dma_chan_data *chan, @@ -1397,7 +1399,7 @@ static inline void dw_dma_interrupt_unregister(struct dma *dma, int channel) static int dw_dma_probe(struct dma *dma) { struct dma_pdata *dw_pdata; - int i; + int i, ret; if (dma_get_drvdata(dma)) return -EEXIST; /* already created */ @@ -1417,7 +1419,9 @@ static int dw_dma_probe(struct dma *dma) spinlock_init(&dma->lock); - dw_dma_setup(dma); + ret = dw_dma_setup(dma); + if (ret < 0) + return ret; /* init work */ for (i = 0; i < dma->plat_data.channels; i++) {