aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2013-12-15 09:16:00 -0500
committerMarc Kleine-Budde <mkl@pengutronix.de>2013-12-17 05:47:21 -0500
commit21629e1a118402566dce08f26edf19954fecef32 (patch)
tree94a2acb43dabab9f92ff0197f14d4b54d6a23a42 /drivers/net/can
parent05780d9808f72dc28a5c3602e11a7c53aef972ad (diff)
can: mcp251x: Convert to devm-* API
Replace existing resource handling in the driver with managed device resource, this ensures more consistent error values and simplifies error paths. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/mcp251x.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index c4970c8b949a..88d3877b6277 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -1066,15 +1066,17 @@ static int mcp251x_can_probe(struct spi_device *spi)
1066 1066
1067 /* Allocate non-DMA buffers */ 1067 /* Allocate non-DMA buffers */
1068 if (!mcp251x_enable_dma) { 1068 if (!mcp251x_enable_dma) {
1069 priv->spi_tx_buf = kmalloc(SPI_TRANSFER_BUF_LEN, GFP_KERNEL); 1069 priv->spi_tx_buf = devm_kzalloc(&spi->dev, SPI_TRANSFER_BUF_LEN,
1070 GFP_KERNEL);
1070 if (!priv->spi_tx_buf) { 1071 if (!priv->spi_tx_buf) {
1071 ret = -ENOMEM; 1072 ret = -ENOMEM;
1072 goto error_tx_buf; 1073 goto error_probe;
1073 } 1074 }
1074 priv->spi_rx_buf = kmalloc(SPI_TRANSFER_BUF_LEN, GFP_KERNEL); 1075 priv->spi_rx_buf = devm_kzalloc(&spi->dev, SPI_TRANSFER_BUF_LEN,
1076 GFP_KERNEL);
1075 if (!priv->spi_rx_buf) { 1077 if (!priv->spi_rx_buf) {
1076 ret = -ENOMEM; 1078 ret = -ENOMEM;
1077 goto error_rx_buf; 1079 goto error_probe;
1078 } 1080 }
1079 } 1081 }
1080 1082
@@ -1107,12 +1109,6 @@ static int mcp251x_can_probe(struct spi_device *spi)
1107 return ret; 1109 return ret;
1108 1110
1109error_probe: 1111error_probe:
1110 if (!mcp251x_enable_dma)
1111 kfree(priv->spi_rx_buf);
1112error_rx_buf:
1113 if (!mcp251x_enable_dma)
1114 kfree(priv->spi_tx_buf);
1115error_tx_buf:
1116 if (mcp251x_enable_dma) 1112 if (mcp251x_enable_dma)
1117 dma_free_coherent(&spi->dev, PAGE_SIZE, 1113 dma_free_coherent(&spi->dev, PAGE_SIZE,
1118 priv->spi_tx_buf, priv->spi_tx_dma); 1114 priv->spi_tx_buf, priv->spi_tx_dma);
@@ -1135,9 +1131,6 @@ static int mcp251x_can_remove(struct spi_device *spi)
1135 if (mcp251x_enable_dma) { 1131 if (mcp251x_enable_dma) {
1136 dma_free_coherent(&spi->dev, PAGE_SIZE, 1132 dma_free_coherent(&spi->dev, PAGE_SIZE,
1137 priv->spi_tx_buf, priv->spi_tx_dma); 1133 priv->spi_tx_buf, priv->spi_tx_dma);
1138 } else {
1139 kfree(priv->spi_tx_buf);
1140 kfree(priv->spi_rx_buf);
1141 } 1134 }
1142 1135
1143 mcp251x_power_enable(priv->power, 0); 1136 mcp251x_power_enable(priv->power, 0);