mtd: rawnand: marvell: Release DMA channel on error

Release the DMA channel on errors after the channel has been successfully
requested.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200227123749.24064-3-peter.ujfalusi@ti.com
This commit is contained in:
Peter Ujfalusi 2020-02-27 14:37:44 +02:00 committed by Miquel Raynal
parent 7cd8c0adb4
commit aafe30baf4

View File

@ -2751,8 +2751,10 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc)
} }
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) if (!r) {
return -ENXIO; ret = -ENXIO;
goto release_channel;
}
config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
@ -2763,7 +2765,7 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc)
ret = dmaengine_slave_config(nfc->dma_chan, &config); ret = dmaengine_slave_config(nfc->dma_chan, &config);
if (ret < 0) { if (ret < 0) {
dev_err(nfc->dev, "Failed to configure DMA channel\n"); dev_err(nfc->dev, "Failed to configure DMA channel\n");
return ret; goto release_channel;
} }
/* /*
@ -2773,12 +2775,20 @@ static int marvell_nfc_init_dma(struct marvell_nfc *nfc)
* the provided buffer. * the provided buffer.
*/ */
nfc->dma_buf = kmalloc(MAX_CHUNK_SIZE, GFP_KERNEL | GFP_DMA); nfc->dma_buf = kmalloc(MAX_CHUNK_SIZE, GFP_KERNEL | GFP_DMA);
if (!nfc->dma_buf) if (!nfc->dma_buf) {
return -ENOMEM; ret = -ENOMEM;
goto release_channel;
}
nfc->use_dma = true; nfc->use_dma = true;
return 0; return 0;
release_channel:
dma_release_channel(nfc->dma_chan);
nfc->dma_chan = NULL;
return ret;
} }
static void marvell_nfc_reset(struct marvell_nfc *nfc) static void marvell_nfc_reset(struct marvell_nfc *nfc)
@ -2920,10 +2930,13 @@ static int marvell_nfc_probe(struct platform_device *pdev)
ret = marvell_nand_chips_init(dev, nfc); ret = marvell_nand_chips_init(dev, nfc);
if (ret) if (ret)
goto unprepare_reg_clk; goto release_dma;
return 0; return 0;
release_dma:
if (nfc->use_dma)
dma_release_channel(nfc->dma_chan);
unprepare_reg_clk: unprepare_reg_clk:
clk_disable_unprepare(nfc->reg_clk); clk_disable_unprepare(nfc->reg_clk);
unprepare_core_clk: unprepare_core_clk: