Commit 3a73aeff authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Marc Kleine-Budde
Browse files

can: mcp251x: Use dmam_alloc_coherent



This patch moves the data allocated using dma_alloc_coherent to the
corresponding managed interface and does away with the calls to free the
allocated memory in the probe and remove functions.

Signed-off-by: default avatarHimangi Saraogi <himangi774@gmail.com>
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent b25a4372
Loading
Loading
Loading
Loading
+4 −12
Original line number Original line Diff line number Diff line
@@ -1107,7 +1107,7 @@ static int mcp251x_can_probe(struct spi_device *spi)
		 * Minimum coherent DMA allocation is PAGE_SIZE, so allocate
		 * Minimum coherent DMA allocation is PAGE_SIZE, so allocate
		 * that much and share it between Tx and Rx DMA buffers.
		 * that much and share it between Tx and Rx DMA buffers.
		 */
		 */
		priv->spi_tx_buf = dma_alloc_coherent(&spi->dev,
		priv->spi_tx_buf = dmam_alloc_coherent(&spi->dev,
						       PAGE_SIZE,
						       PAGE_SIZE,
						       &priv->spi_tx_dma,
						       &priv->spi_tx_dma,
						       GFP_DMA);
						       GFP_DMA);
@@ -1156,9 +1156,6 @@ static int mcp251x_can_probe(struct spi_device *spi)
	return 0;
	return 0;


error_probe:
error_probe:
	if (mcp251x_enable_dma)
		dma_free_coherent(&spi->dev, PAGE_SIZE,
				  priv->spi_tx_buf, priv->spi_tx_dma);
	mcp251x_power_enable(priv->power, 0);
	mcp251x_power_enable(priv->power, 0);


out_clk:
out_clk:
@@ -1178,11 +1175,6 @@ static int mcp251x_can_remove(struct spi_device *spi)


	unregister_candev(net);
	unregister_candev(net);


	if (mcp251x_enable_dma) {
		dma_free_coherent(&spi->dev, PAGE_SIZE,
				  priv->spi_tx_buf, priv->spi_tx_dma);
	}

	mcp251x_power_enable(priv->power, 0);
	mcp251x_power_enable(priv->power, 0);


	if (!IS_ERR(priv->clk))
	if (!IS_ERR(priv->clk))