aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-03-29 09:37:44 -0400
committerMark Brown <broonie@linaro.org>2014-04-03 06:21:15 -0400
commita6f936db640f56066d0728bc135c1acd4cd9e56e (patch)
tree228b3eed2b5f69e82f5d4c7467d640a249b877e2 /drivers/spi/spi-omap2-mcspi.c
parent455c6fdbd219161bd09b1165f11699d6d73de11c (diff)
spi: omap2-mcspi: Convert to use devm_kcalloc
This saves a few unwind code and return proper error if devm_kcalloc fails. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index a72127f08e39..f664212fb4ed 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1356,12 +1356,13 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1356 1356
1357 INIT_LIST_HEAD(&mcspi->ctx.cs); 1357 INIT_LIST_HEAD(&mcspi->ctx.cs);
1358 1358
1359 mcspi->dma_channels = kcalloc(master->num_chipselect, 1359 mcspi->dma_channels = devm_kcalloc(&pdev->dev, master->num_chipselect,
1360 sizeof(struct omap2_mcspi_dma), 1360 sizeof(struct omap2_mcspi_dma),
1361 GFP_KERNEL); 1361 GFP_KERNEL);
1362 1362 if (mcspi->dma_channels == NULL) {
1363 if (mcspi->dma_channels == NULL) 1363 status = -ENOMEM;
1364 goto free_master; 1364 goto free_master;
1365 }
1365 1366
1366 for (i = 0; i < master->num_chipselect; i++) { 1367 for (i = 0; i < master->num_chipselect; i++) {
1367 char *dma_rx_ch_name = mcspi->dma_channels[i].dma_rx_ch_name; 1368 char *dma_rx_ch_name = mcspi->dma_channels[i].dma_rx_ch_name;
@@ -1403,7 +1404,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1403 } 1404 }
1404 1405
1405 if (status < 0) 1406 if (status < 0)
1406 goto dma_chnl_free; 1407 goto free_master;
1407 1408
1408 pm_runtime_use_autosuspend(&pdev->dev); 1409 pm_runtime_use_autosuspend(&pdev->dev);
1409 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); 1410 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);
@@ -1421,8 +1422,6 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1421 1422
1422disable_pm: 1423disable_pm:
1423 pm_runtime_disable(&pdev->dev); 1424 pm_runtime_disable(&pdev->dev);
1424dma_chnl_free:
1425 kfree(mcspi->dma_channels);
1426free_master: 1425free_master:
1427 spi_master_put(master); 1426 spi_master_put(master);
1428 return status; 1427 return status;
@@ -1430,19 +1429,12 @@ free_master:
1430 1429
1431static int omap2_mcspi_remove(struct platform_device *pdev) 1430static int omap2_mcspi_remove(struct platform_device *pdev)
1432{ 1431{
1433 struct spi_master *master; 1432 struct spi_master *master = platform_get_drvdata(pdev);
1434 struct omap2_mcspi *mcspi; 1433 struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
1435 struct omap2_mcspi_dma *dma_channels;
1436
1437 master = platform_get_drvdata(pdev);
1438 mcspi = spi_master_get_devdata(master);
1439 dma_channels = mcspi->dma_channels;
1440 1434
1441 pm_runtime_put_sync(mcspi->dev); 1435 pm_runtime_put_sync(mcspi->dev);
1442 pm_runtime_disable(&pdev->dev); 1436 pm_runtime_disable(&pdev->dev);
1443 1437
1444 kfree(dma_channels);
1445
1446 return 0; 1438 return 0;
1447} 1439}
1448 1440