summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-dw-core.c
diff options
context:
space:
mode:
authorSerge Semin <Sergey.Semin@baikalelectronics.ru>2022-06-25 00:06:23 +0300
committerMark Brown <broonie@kernel.org>2022-06-27 13:24:33 +0100
commite95a1cd2cfe722dc8434db6de33958035853aa05 (patch)
tree82b0585218d4a6baa5ba1c6339081276da8f1f30 /drivers/spi/spi-dw-core.c
parenta813c47d22b0a0c51567292bc198a39bdcdc3799 (diff)
spi: dw: Add deferred DMA-channels setup support
Currently if the source DMA device isn't ready to provide the channels capable of the SPI DMA transfers, the DW SSI controller will be registered with no DMA support. It isn't right since all what the driver needs to do is to postpone the probe procedure until the DMA device is ready. Let's fix that in the framework of the DWC SSI generic DMA implementation. First we need to use the dma_request_chan() method instead of the dma_request_slave_channel() function, because the later one is deprecated and most importantly doesn't return the failure cause but the NULL-pointer. Second we need to stop the DW SSI controller probe procedure if the -EPROBE_DEFER error is returned on the DMA initialization. The procedure will resume later when the channels are ready to be requested. Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20220624210623.6383-1-Sergey.Semin@baikalelectronics.ru Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-dw-core.c')
-rw-r--r--drivers/spi/spi-dw-core.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
index ecea471ff42c..911ea9bddbee 100644
--- a/drivers/spi/spi-dw-core.c
+++ b/drivers/spi/spi-dw-core.c
@@ -942,7 +942,9 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
if (dws->dma_ops && dws->dma_ops->dma_init) {
ret = dws->dma_ops->dma_init(dev, dws);
- if (ret) {
+ if (ret == -EPROBE_DEFER) {
+ goto err_free_irq;
+ } else if (ret) {
dev_warn(dev, "DMA init failed\n");
} else {
master->can_dma = dws->dma_ops->can_dma;
@@ -963,6 +965,7 @@ err_dma_exit:
if (dws->dma_ops && dws->dma_ops->dma_exit)
dws->dma_ops->dma_exit(dws);
dw_spi_enable_chip(dws, 0);
+err_free_irq:
free_irq(dws->irq, master);
err_free_master:
spi_controller_put(master);