Skip to content

Commit f0f3b5f

Browse files
KiranPadwalVinod Koul
authored andcommitted
dma: cppi41: Switch to using managed resource in probe
This change uses managed resource APIs to allocate resources such as, mem, irq in order to simplify the driver unload or failure cases Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
1 parent 6e4a2a8 commit f0f3b5f

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

‎drivers/dma/cppi41.c‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
938938
if (!glue_info)
939939
return -EINVAL;
940940

941-
cdd = kzalloc(sizeof(*cdd), GFP_KERNEL);
941+
cdd = devm_kzalloc(&pdev->dev, sizeof(*cdd), GFP_KERNEL);
942942
if (!cdd)
943943
return -ENOMEM;
944944

@@ -959,10 +959,8 @@ static int cppi41_dma_probe(struct platform_device *pdev)
959959
cdd->qmgr_mem = of_iomap(dev->of_node, 3);
960960

961961
if (!cdd->usbss_mem || !cdd->ctrl_mem || !cdd->sched_mem ||
962-
!cdd->qmgr_mem) {
963-
ret = -ENXIO;
964-
goto err_remap;
965-
}
962+
!cdd->qmgr_mem)
963+
return -ENXIO;
966964

967965
pm_runtime_enable(dev);
968966
ret = pm_runtime_get_sync(dev);
@@ -989,7 +987,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
989987

990988
cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER);
991989

992-
ret = request_irq(irq, glue_info->isr, IRQF_SHARED,
990+
ret = devm_request_irq(&pdev->dev, irq, glue_info->isr, IRQF_SHARED,
993991
dev_name(dev), cdd);
994992
if (ret)
995993
goto err_irq;
@@ -1009,7 +1007,6 @@ static int cppi41_dma_probe(struct platform_device *pdev)
10091007
err_of:
10101008
dma_async_device_unregister(&cdd->ddev);
10111009
err_dma_reg:
1012-
free_irq(irq, cdd);
10131010
err_irq:
10141011
cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
10151012
cleanup_chans(cdd);
@@ -1023,8 +1020,6 @@ static int cppi41_dma_probe(struct platform_device *pdev)
10231020
iounmap(cdd->ctrl_mem);
10241021
iounmap(cdd->sched_mem);
10251022
iounmap(cdd->qmgr_mem);
1026-
err_remap:
1027-
kfree(cdd);
10281023
return ret;
10291024
}
10301025

@@ -1036,7 +1031,7 @@ static int cppi41_dma_remove(struct platform_device *pdev)
10361031
dma_async_device_unregister(&cdd->ddev);
10371032

10381033
cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
1039-
free_irq(cdd->irq, cdd);
1034+
devm_free_irq(&pdev->dev, cdd->irq, cdd);
10401035
cleanup_chans(cdd);
10411036
deinit_cppi41(&pdev->dev, cdd);
10421037
iounmap(cdd->usbss_mem);
@@ -1045,7 +1040,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
10451040
iounmap(cdd->qmgr_mem);
10461041
pm_runtime_put(&pdev->dev);
10471042
pm_runtime_disable(&pdev->dev);
1048-
kfree(cdd);
10491043
return 0;
10501044
}
10511045

0 commit comments

Comments
 (0)