diff options
author | Kiran Padwal <kiran.padwal@smartplayin.com> | 2014-09-24 06:23:46 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2014-10-15 10:56:45 -0400 |
commit | f0f3b5fa7537e13dfd20b4cd399f00545f9fc0e7 (patch) | |
tree | c0257efe392080636f59619c177d64213eb9d243 /drivers/dma/cppi41.c | |
parent | 6e4a2a83f95826201bbd89f55522537ea52d1d67 (diff) |
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>
Diffstat (limited to 'drivers/dma/cppi41.c')
-rw-r--r-- | drivers/dma/cppi41.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index 8f8b0b608875..a58eec3b2cad 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c | |||
@@ -938,7 +938,7 @@ static int cppi41_dma_probe(struct platform_device *pdev) | |||
938 | if (!glue_info) | 938 | if (!glue_info) |
939 | return -EINVAL; | 939 | return -EINVAL; |
940 | 940 | ||
941 | cdd = kzalloc(sizeof(*cdd), GFP_KERNEL); | 941 | cdd = devm_kzalloc(&pdev->dev, sizeof(*cdd), GFP_KERNEL); |
942 | if (!cdd) | 942 | if (!cdd) |
943 | return -ENOMEM; | 943 | return -ENOMEM; |
944 | 944 | ||
@@ -959,10 +959,8 @@ static int cppi41_dma_probe(struct platform_device *pdev) | |||
959 | cdd->qmgr_mem = of_iomap(dev->of_node, 3); | 959 | cdd->qmgr_mem = of_iomap(dev->of_node, 3); |
960 | 960 | ||
961 | if (!cdd->usbss_mem || !cdd->ctrl_mem || !cdd->sched_mem || | 961 | if (!cdd->usbss_mem || !cdd->ctrl_mem || !cdd->sched_mem || |
962 | !cdd->qmgr_mem) { | 962 | !cdd->qmgr_mem) |
963 | ret = -ENXIO; | 963 | return -ENXIO; |
964 | goto err_remap; | ||
965 | } | ||
966 | 964 | ||
967 | pm_runtime_enable(dev); | 965 | pm_runtime_enable(dev); |
968 | ret = pm_runtime_get_sync(dev); | 966 | ret = pm_runtime_get_sync(dev); |
@@ -989,7 +987,7 @@ static int cppi41_dma_probe(struct platform_device *pdev) | |||
989 | 987 | ||
990 | cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER); | 988 | cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER); |
991 | 989 | ||
992 | ret = request_irq(irq, glue_info->isr, IRQF_SHARED, | 990 | ret = devm_request_irq(&pdev->dev, irq, glue_info->isr, IRQF_SHARED, |
993 | dev_name(dev), cdd); | 991 | dev_name(dev), cdd); |
994 | if (ret) | 992 | if (ret) |
995 | goto err_irq; | 993 | goto err_irq; |
@@ -1009,7 +1007,6 @@ static int cppi41_dma_probe(struct platform_device *pdev) | |||
1009 | err_of: | 1007 | err_of: |
1010 | dma_async_device_unregister(&cdd->ddev); | 1008 | dma_async_device_unregister(&cdd->ddev); |
1011 | err_dma_reg: | 1009 | err_dma_reg: |
1012 | free_irq(irq, cdd); | ||
1013 | err_irq: | 1010 | err_irq: |
1014 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); | 1011 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); |
1015 | cleanup_chans(cdd); | 1012 | cleanup_chans(cdd); |
@@ -1023,8 +1020,6 @@ err_get_sync: | |||
1023 | iounmap(cdd->ctrl_mem); | 1020 | iounmap(cdd->ctrl_mem); |
1024 | iounmap(cdd->sched_mem); | 1021 | iounmap(cdd->sched_mem); |
1025 | iounmap(cdd->qmgr_mem); | 1022 | iounmap(cdd->qmgr_mem); |
1026 | err_remap: | ||
1027 | kfree(cdd); | ||
1028 | return ret; | 1023 | return ret; |
1029 | } | 1024 | } |
1030 | 1025 | ||
@@ -1036,7 +1031,7 @@ static int cppi41_dma_remove(struct platform_device *pdev) | |||
1036 | dma_async_device_unregister(&cdd->ddev); | 1031 | dma_async_device_unregister(&cdd->ddev); |
1037 | 1032 | ||
1038 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); | 1033 | cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR); |
1039 | free_irq(cdd->irq, cdd); | 1034 | devm_free_irq(&pdev->dev, cdd->irq, cdd); |
1040 | cleanup_chans(cdd); | 1035 | cleanup_chans(cdd); |
1041 | deinit_cppi41(&pdev->dev, cdd); | 1036 | deinit_cppi41(&pdev->dev, cdd); |
1042 | iounmap(cdd->usbss_mem); | 1037 | iounmap(cdd->usbss_mem); |
@@ -1045,7 +1040,6 @@ static int cppi41_dma_remove(struct platform_device *pdev) | |||
1045 | iounmap(cdd->qmgr_mem); | 1040 | iounmap(cdd->qmgr_mem); |
1046 | pm_runtime_put(&pdev->dev); | 1041 | pm_runtime_put(&pdev->dev); |
1047 | pm_runtime_disable(&pdev->dev); | 1042 | pm_runtime_disable(&pdev->dev); |
1048 | kfree(cdd); | ||
1049 | return 0; | 1043 | return 0; |
1050 | } | 1044 | } |
1051 | 1045 | ||