]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: stm32: properly fail on dma_request_chan error
authorAlain Volmat <alain.volmat@foss.st.com>
Thu, 18 Dec 2025 10:48:27 +0000 (11:48 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 18 Dec 2025 10:59:32 +0000 (10:59 +0000)
Correct handling of the dma_request_chan call in order to avoid
misleading warn message if no DMA is provided within the device-tree
and moreover fail if dma_request_chan has returned a valid error.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Link: https://patch.msgid.link/20251218-stm32-spi-enhancements-v2-1-3b69901ca9fe@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-stm32.c

index 2c804c1aef989db6376e3eef8c37a02b73138e0a..40651b6050f6865a3dca21d94ffdf27c50653ae0 100644 (file)
@@ -2406,11 +2406,13 @@ static int stm32_spi_probe(struct platform_device *pdev)
        spi->dma_tx = dma_request_chan(spi->dev, "tx");
        if (IS_ERR(spi->dma_tx)) {
                ret = PTR_ERR(spi->dma_tx);
-               spi->dma_tx = NULL;
-               if (ret == -EPROBE_DEFER)
+               if (ret == -ENODEV) {
+                       dev_info(&pdev->dev, "tx dma disabled\n");
+                       spi->dma_tx = NULL;
+               } else {
+                       dev_err_probe(&pdev->dev, ret, "failed to request tx dma channel\n");
                        goto err_clk_disable;
-
-               dev_warn(&pdev->dev, "failed to request tx dma channel\n");
+               }
        } else {
                ctrl->dma_tx = spi->dma_tx;
        }
@@ -2418,11 +2420,13 @@ static int stm32_spi_probe(struct platform_device *pdev)
        spi->dma_rx = dma_request_chan(spi->dev, "rx");
        if (IS_ERR(spi->dma_rx)) {
                ret = PTR_ERR(spi->dma_rx);
-               spi->dma_rx = NULL;
-               if (ret == -EPROBE_DEFER)
+               if (ret == -ENODEV) {
+                       dev_info(&pdev->dev, "rx dma disabled\n");
+                       spi->dma_rx = NULL;
+               } else {
+                       dev_err_probe(&pdev->dev, ret, "failed to request rx dma channel\n");
                        goto err_dma_release;
-
-               dev_warn(&pdev->dev, "failed to request rx dma channel\n");
+               }
        } else {
                ctrl->dma_rx = spi->dma_rx;
        }