diff options
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 2941c5b96ebc..4dc77df38864 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -1379,12 +1379,13 @@ static int omap2_mcspi_probe(struct platform_device *pdev) | |||
1379 | 1379 | ||
1380 | INIT_LIST_HEAD(&mcspi->ctx.cs); | 1380 | INIT_LIST_HEAD(&mcspi->ctx.cs); |
1381 | 1381 | ||
1382 | mcspi->dma_channels = kcalloc(master->num_chipselect, | 1382 | mcspi->dma_channels = devm_kcalloc(&pdev->dev, master->num_chipselect, |
1383 | sizeof(struct omap2_mcspi_dma), | 1383 | sizeof(struct omap2_mcspi_dma), |
1384 | GFP_KERNEL); | 1384 | GFP_KERNEL); |
1385 | 1385 | if (mcspi->dma_channels == NULL) { | |
1386 | if (mcspi->dma_channels == NULL) | 1386 | status = -ENOMEM; |
1387 | goto free_master; | 1387 | goto free_master; |
1388 | } | ||
1388 | 1389 | ||
1389 | for (i = 0; i < master->num_chipselect; i++) { | 1390 | for (i = 0; i < master->num_chipselect; i++) { |
1390 | char *dma_rx_ch_name = mcspi->dma_channels[i].dma_rx_ch_name; | 1391 | char *dma_rx_ch_name = mcspi->dma_channels[i].dma_rx_ch_name; |
@@ -1426,7 +1427,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev) | |||
1426 | } | 1427 | } |
1427 | 1428 | ||
1428 | if (status < 0) | 1429 | if (status < 0) |
1429 | goto dma_chnl_free; | 1430 | goto free_master; |
1430 | 1431 | ||
1431 | pm_runtime_use_autosuspend(&pdev->dev); | 1432 | pm_runtime_use_autosuspend(&pdev->dev); |
1432 | pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); | 1433 | pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); |
@@ -1444,8 +1445,6 @@ static int omap2_mcspi_probe(struct platform_device *pdev) | |||
1444 | 1445 | ||
1445 | disable_pm: | 1446 | disable_pm: |
1446 | pm_runtime_disable(&pdev->dev); | 1447 | pm_runtime_disable(&pdev->dev); |
1447 | dma_chnl_free: | ||
1448 | kfree(mcspi->dma_channels); | ||
1449 | free_master: | 1448 | free_master: |
1450 | spi_master_put(master); | 1449 | spi_master_put(master); |
1451 | return status; | 1450 | return status; |
@@ -1453,19 +1452,12 @@ free_master: | |||
1453 | 1452 | ||
1454 | static int omap2_mcspi_remove(struct platform_device *pdev) | 1453 | static int omap2_mcspi_remove(struct platform_device *pdev) |
1455 | { | 1454 | { |
1456 | struct spi_master *master; | 1455 | struct spi_master *master = platform_get_drvdata(pdev); |
1457 | struct omap2_mcspi *mcspi; | 1456 | struct omap2_mcspi *mcspi = spi_master_get_devdata(master); |
1458 | struct omap2_mcspi_dma *dma_channels; | ||
1459 | |||
1460 | master = platform_get_drvdata(pdev); | ||
1461 | mcspi = spi_master_get_devdata(master); | ||
1462 | dma_channels = mcspi->dma_channels; | ||
1463 | 1457 | ||
1464 | pm_runtime_put_sync(mcspi->dev); | 1458 | pm_runtime_put_sync(mcspi->dev); |
1465 | pm_runtime_disable(&pdev->dev); | 1459 | pm_runtime_disable(&pdev->dev); |
1466 | 1460 | ||
1467 | kfree(dma_channels); | ||
1468 | |||
1469 | return 0; | 1461 | return 0; |
1470 | } | 1462 | } |
1471 | 1463 | ||