diff options
Diffstat (limited to 'drivers/dma/imx-dma.c')
-rw-r--r-- | drivers/dma/imx-dma.c | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c index f11b5b2b1a1c..1f2b79009d69 100644 --- a/drivers/dma/imx-dma.c +++ b/drivers/dma/imx-dma.c | |||
@@ -962,7 +962,7 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
962 | int ret, i; | 962 | int ret, i; |
963 | 963 | ||
964 | 964 | ||
965 | imxdma = kzalloc(sizeof(*imxdma), GFP_KERNEL); | 965 | imxdma = devm_kzalloc(&pdev->dev, sizeof(*imxdma), GFP_KERNEL); |
966 | if (!imxdma) | 966 | if (!imxdma) |
967 | return -ENOMEM; | 967 | return -ENOMEM; |
968 | 968 | ||
@@ -978,16 +978,12 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
978 | } | 978 | } |
979 | 979 | ||
980 | imxdma->dma_ipg = devm_clk_get(&pdev->dev, "ipg"); | 980 | imxdma->dma_ipg = devm_clk_get(&pdev->dev, "ipg"); |
981 | if (IS_ERR(imxdma->dma_ipg)) { | 981 | if (IS_ERR(imxdma->dma_ipg)) |
982 | ret = PTR_ERR(imxdma->dma_ipg); | 982 | return PTR_ERR(imxdma->dma_ipg); |
983 | goto err_clk; | ||
984 | } | ||
985 | 983 | ||
986 | imxdma->dma_ahb = devm_clk_get(&pdev->dev, "ahb"); | 984 | imxdma->dma_ahb = devm_clk_get(&pdev->dev, "ahb"); |
987 | if (IS_ERR(imxdma->dma_ahb)) { | 985 | if (IS_ERR(imxdma->dma_ahb)) |
988 | ret = PTR_ERR(imxdma->dma_ahb); | 986 | return PTR_ERR(imxdma->dma_ahb); |
989 | goto err_clk; | ||
990 | } | ||
991 | 987 | ||
992 | clk_prepare_enable(imxdma->dma_ipg); | 988 | clk_prepare_enable(imxdma->dma_ipg); |
993 | clk_prepare_enable(imxdma->dma_ahb); | 989 | clk_prepare_enable(imxdma->dma_ahb); |
@@ -996,17 +992,18 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
996 | imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR); | 992 | imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR); |
997 | 993 | ||
998 | if (cpu_is_mx1()) { | 994 | if (cpu_is_mx1()) { |
999 | ret = request_irq(MX1_DMA_INT, dma_irq_handler, 0, "DMA", imxdma); | 995 | ret = devm_request_irq(&pdev->dev, MX1_DMA_INT, |
996 | dma_irq_handler, 0, "DMA", imxdma); | ||
1000 | if (ret) { | 997 | if (ret) { |
1001 | dev_warn(imxdma->dev, "Can't register IRQ for DMA\n"); | 998 | dev_warn(imxdma->dev, "Can't register IRQ for DMA\n"); |
1002 | goto err_enable; | 999 | goto err; |
1003 | } | 1000 | } |
1004 | 1001 | ||
1005 | ret = request_irq(MX1_DMA_ERR, imxdma_err_handler, 0, "DMA", imxdma); | 1002 | ret = devm_request_irq(&pdev->dev, MX1_DMA_ERR, |
1003 | imxdma_err_handler, 0, "DMA", imxdma); | ||
1006 | if (ret) { | 1004 | if (ret) { |
1007 | dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n"); | 1005 | dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n"); |
1008 | free_irq(MX1_DMA_INT, NULL); | 1006 | goto err; |
1009 | goto err_enable; | ||
1010 | } | 1007 | } |
1011 | } | 1008 | } |
1012 | 1009 | ||
@@ -1037,13 +1034,13 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
1037 | struct imxdma_channel *imxdmac = &imxdma->channel[i]; | 1034 | struct imxdma_channel *imxdmac = &imxdma->channel[i]; |
1038 | 1035 | ||
1039 | if (cpu_is_mx21() || cpu_is_mx27()) { | 1036 | if (cpu_is_mx21() || cpu_is_mx27()) { |
1040 | ret = request_irq(MX2x_INT_DMACH0 + i, | 1037 | ret = devm_request_irq(&pdev->dev, MX2x_INT_DMACH0 + i, |
1041 | dma_irq_handler, 0, "DMA", imxdma); | 1038 | dma_irq_handler, 0, "DMA", imxdma); |
1042 | if (ret) { | 1039 | if (ret) { |
1043 | dev_warn(imxdma->dev, "Can't register IRQ %d " | 1040 | dev_warn(imxdma->dev, "Can't register IRQ %d " |
1044 | "for DMA channel %d\n", | 1041 | "for DMA channel %d\n", |
1045 | MX2x_INT_DMACH0 + i, i); | 1042 | MX2x_INT_DMACH0 + i, i); |
1046 | goto err_init; | 1043 | goto err; |
1047 | } | 1044 | } |
1048 | init_timer(&imxdmac->watchdog); | 1045 | init_timer(&imxdmac->watchdog); |
1049 | imxdmac->watchdog.function = &imxdma_watchdog; | 1046 | imxdmac->watchdog.function = &imxdma_watchdog; |
@@ -1089,46 +1086,25 @@ static int __init imxdma_probe(struct platform_device *pdev) | |||
1089 | ret = dma_async_device_register(&imxdma->dma_device); | 1086 | ret = dma_async_device_register(&imxdma->dma_device); |
1090 | if (ret) { | 1087 | if (ret) { |
1091 | dev_err(&pdev->dev, "unable to register\n"); | 1088 | dev_err(&pdev->dev, "unable to register\n"); |
1092 | goto err_init; | 1089 | goto err; |
1093 | } | 1090 | } |
1094 | 1091 | ||
1095 | return 0; | 1092 | return 0; |
1096 | 1093 | ||
1097 | err_init: | 1094 | err: |
1098 | |||
1099 | if (cpu_is_mx21() || cpu_is_mx27()) { | ||
1100 | while (--i >= 0) | ||
1101 | free_irq(MX2x_INT_DMACH0 + i, NULL); | ||
1102 | } else if cpu_is_mx1() { | ||
1103 | free_irq(MX1_DMA_INT, NULL); | ||
1104 | free_irq(MX1_DMA_ERR, NULL); | ||
1105 | } | ||
1106 | err_enable: | ||
1107 | clk_disable_unprepare(imxdma->dma_ipg); | 1095 | clk_disable_unprepare(imxdma->dma_ipg); |
1108 | clk_disable_unprepare(imxdma->dma_ahb); | 1096 | clk_disable_unprepare(imxdma->dma_ahb); |
1109 | err_clk: | ||
1110 | kfree(imxdma); | ||
1111 | return ret; | 1097 | return ret; |
1112 | } | 1098 | } |
1113 | 1099 | ||
1114 | static int __exit imxdma_remove(struct platform_device *pdev) | 1100 | static int __exit imxdma_remove(struct platform_device *pdev) |
1115 | { | 1101 | { |
1116 | struct imxdma_engine *imxdma = platform_get_drvdata(pdev); | 1102 | struct imxdma_engine *imxdma = platform_get_drvdata(pdev); |
1117 | int i; | ||
1118 | 1103 | ||
1119 | dma_async_device_unregister(&imxdma->dma_device); | 1104 | dma_async_device_unregister(&imxdma->dma_device); |
1120 | 1105 | ||
1121 | if (cpu_is_mx21() || cpu_is_mx27()) { | ||
1122 | for (i = 0; i < IMX_DMA_CHANNELS; i++) | ||
1123 | free_irq(MX2x_INT_DMACH0 + i, NULL); | ||
1124 | } else if cpu_is_mx1() { | ||
1125 | free_irq(MX1_DMA_INT, NULL); | ||
1126 | free_irq(MX1_DMA_ERR, NULL); | ||
1127 | } | ||
1128 | |||
1129 | clk_disable_unprepare(imxdma->dma_ipg); | 1106 | clk_disable_unprepare(imxdma->dma_ipg); |
1130 | clk_disable_unprepare(imxdma->dma_ahb); | 1107 | clk_disable_unprepare(imxdma->dma_ahb); |
1131 | kfree(imxdma); | ||
1132 | 1108 | ||
1133 | return 0; | 1109 | return 0; |
1134 | } | 1110 | } |