diff mbox series

[RFC,1/3,stable-6.1] spi: spi-atmel: switch to managed dma_alloc_coherent

Message ID c8ac6625-a2d8-171d-f1b5-ad72e34a7645@pcs.com
State New
Headers show
Series [RFC,1/3,stable-6.1] spi: spi-atmel: switch to managed dma_alloc_coherent | expand

Commit Message

Thomas Pfaff Nov. 15, 2023, 1:59 p.m. UTC
From: Thomas Pfaff <tpfaff@pcs.com>

use managed dma_alloc_coherent instead of unmanaged.

Signed-off-by: Thomas Pfaff <tpfaff@pcs.com>
---
diff mbox series

Patch

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index c4f22d50dba5..fc566d22aa36 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1513,22 +1513,22 @@  static int atmel_spi_probe(struct platform_device *pdev)
 	}
 
 	if (IS_ENABLED(CONFIG_SOC_SAM_V4_V5)) {
-		as->addr_rx_bbuf = dma_alloc_coherent(&pdev->dev,
-						      SPI_MAX_DMA_XFER,
-						      &as->dma_addr_rx_bbuf,
-						      GFP_KERNEL | GFP_DMA);
+		as->addr_rx_bbuf = dmam_alloc_coherent(&pdev->dev,
+						       SPI_MAX_DMA_XFER,
+						       &as->dma_addr_rx_bbuf,
+						       GFP_KERNEL | GFP_DMA);
 		if (!as->addr_rx_bbuf) {
 			as->use_dma = false;
 		} else {
-			as->addr_tx_bbuf = dma_alloc_coherent(&pdev->dev,
-					SPI_MAX_DMA_XFER,
-					&as->dma_addr_tx_bbuf,
-					GFP_KERNEL | GFP_DMA);
+			as->addr_tx_bbuf = dmam_alloc_coherent(&pdev->dev,
+							       SPI_MAX_DMA_XFER,
+							       &as->dma_addr_tx_bbuf,
+							       GFP_KERNEL | GFP_DMA);
 			if (!as->addr_tx_bbuf) {
 				as->use_dma = false;
-				dma_free_coherent(&pdev->dev, SPI_MAX_DMA_XFER,
-						  as->addr_rx_bbuf,
-						  as->dma_addr_rx_bbuf);
+				dmam_free_coherent(&pdev->dev, SPI_MAX_DMA_XFER,
+						   as->addr_rx_bbuf,
+						   as->dma_addr_rx_bbuf);
 			}
 		}
 		if (!as->use_dma)
@@ -1607,14 +1607,6 @@  static int atmel_spi_remove(struct platform_device *pdev)
 	if (as->use_dma) {
 		atmel_spi_stop_dma(master);
 		atmel_spi_release_dma(master);
-		if (IS_ENABLED(CONFIG_SOC_SAM_V4_V5)) {
-			dma_free_coherent(&pdev->dev, SPI_MAX_DMA_XFER,
-					  as->addr_tx_bbuf,
-					  as->dma_addr_tx_bbuf);
-			dma_free_coherent(&pdev->dev, SPI_MAX_DMA_XFER,
-					  as->addr_rx_bbuf,
-					  as->dma_addr_rx_bbuf);
-		}
 	}
 
 	spin_lock_irq(&as->lock);