spi: spi-ti-qspi: Free DMA resources
Release the RX channel and free the dma coherent memory when
devm_spi_register_master() fails.
Fixes: 5720ec0a6d
("spi: spi-ti-qspi: Add DMA support for QSPI mmap read")
Cc: stable@vger.kernel.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/r/20210218130950.90155-1-tudor.ambarus@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
a38fd87484
commit
1d309cd688
|
@ -733,6 +733,17 @@ static int ti_qspi_runtime_resume(struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ti_qspi_dma_cleanup(struct ti_qspi *qspi)
|
||||||
|
{
|
||||||
|
if (qspi->rx_bb_addr)
|
||||||
|
dma_free_coherent(qspi->dev, QSPI_DMA_BUFFER_SIZE,
|
||||||
|
qspi->rx_bb_addr,
|
||||||
|
qspi->rx_bb_dma_addr);
|
||||||
|
|
||||||
|
if (qspi->rx_chan)
|
||||||
|
dma_release_channel(qspi->rx_chan);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct of_device_id ti_qspi_match[] = {
|
static const struct of_device_id ti_qspi_match[] = {
|
||||||
{.compatible = "ti,dra7xxx-qspi" },
|
{.compatible = "ti,dra7xxx-qspi" },
|
||||||
{.compatible = "ti,am4372-qspi" },
|
{.compatible = "ti,am4372-qspi" },
|
||||||
|
@ -886,6 +897,8 @@ no_dma:
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
ti_qspi_dma_cleanup(qspi);
|
||||||
|
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
free_master:
|
free_master:
|
||||||
spi_master_put(master);
|
spi_master_put(master);
|
||||||
|
@ -904,12 +917,7 @@ static int ti_qspi_remove(struct platform_device *pdev)
|
||||||
pm_runtime_put_sync(&pdev->dev);
|
pm_runtime_put_sync(&pdev->dev);
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
|
|
||||||
if (qspi->rx_bb_addr)
|
ti_qspi_dma_cleanup(qspi);
|
||||||
dma_free_coherent(qspi->dev, QSPI_DMA_BUFFER_SIZE,
|
|
||||||
qspi->rx_bb_addr,
|
|
||||||
qspi->rx_bb_dma_addr);
|
|
||||||
if (qspi->rx_chan)
|
|
||||||
dma_release_channel(qspi->rx_chan);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue