diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-11-15 01:27:50 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-01-08 01:05:04 -0500 |
commit | e4d43c1764bc3ee1150f24e530db2b5b23e91425 (patch) | |
tree | 92ee9654e05cbf0760eccbe13d4663f31a16ce58 /drivers/dma/pl330.c | |
parent | a14acb4ac2a1486f6633c55eb7f7ded07f3ec9fc (diff) |
DMA: PL330: Use devm_* functions
devm_* functions are device managed and make the code and error
handling a bit simpler.
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Diffstat (limited to 'drivers/dma/pl330.c')
-rw-r--r-- | drivers/dma/pl330.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 95555f37ea6d..f7edb6f0ee87 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
@@ -2866,7 +2866,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2866 | pdat = adev->dev.platform_data; | 2866 | pdat = adev->dev.platform_data; |
2867 | 2867 | ||
2868 | /* Allocate a new DMAC and its Channels */ | 2868 | /* Allocate a new DMAC and its Channels */ |
2869 | pdmac = kzalloc(sizeof(*pdmac), GFP_KERNEL); | 2869 | pdmac = devm_kzalloc(&adev->dev, sizeof(*pdmac), GFP_KERNEL); |
2870 | if (!pdmac) { | 2870 | if (!pdmac) { |
2871 | dev_err(&adev->dev, "unable to allocate mem\n"); | 2871 | dev_err(&adev->dev, "unable to allocate mem\n"); |
2872 | return -ENOMEM; | 2872 | return -ENOMEM; |
@@ -2878,13 +2878,9 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2878 | pi->mcbufsz = pdat ? pdat->mcbuf_sz : 0; | 2878 | pi->mcbufsz = pdat ? pdat->mcbuf_sz : 0; |
2879 | 2879 | ||
2880 | res = &adev->res; | 2880 | res = &adev->res; |
2881 | request_mem_region(res->start, resource_size(res), "dma-pl330"); | 2881 | pi->base = devm_request_and_ioremap(&adev->dev, res); |
2882 | 2882 | if (!pi->base) | |
2883 | pi->base = ioremap(res->start, resource_size(res)); | 2883 | return -ENXIO; |
2884 | if (!pi->base) { | ||
2885 | ret = -ENXIO; | ||
2886 | goto probe_err1; | ||
2887 | } | ||
2888 | 2884 | ||
2889 | amba_set_drvdata(adev, pdmac); | 2885 | amba_set_drvdata(adev, pdmac); |
2890 | 2886 | ||
@@ -2892,11 +2888,11 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2892 | ret = request_irq(irq, pl330_irq_handler, 0, | 2888 | ret = request_irq(irq, pl330_irq_handler, 0, |
2893 | dev_name(&adev->dev), pi); | 2889 | dev_name(&adev->dev), pi); |
2894 | if (ret) | 2890 | if (ret) |
2895 | goto probe_err2; | 2891 | return ret; |
2896 | 2892 | ||
2897 | ret = pl330_add(pi); | 2893 | ret = pl330_add(pi); |
2898 | if (ret) | 2894 | if (ret) |
2899 | goto probe_err3; | 2895 | goto probe_err1; |
2900 | 2896 | ||
2901 | INIT_LIST_HEAD(&pdmac->desc_pool); | 2897 | INIT_LIST_HEAD(&pdmac->desc_pool); |
2902 | spin_lock_init(&pdmac->pool_lock); | 2898 | spin_lock_init(&pdmac->pool_lock); |
@@ -2918,7 +2914,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2918 | if (!pdmac->peripherals) { | 2914 | if (!pdmac->peripherals) { |
2919 | ret = -ENOMEM; | 2915 | ret = -ENOMEM; |
2920 | dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n"); | 2916 | dev_err(&adev->dev, "unable to allocate pdmac->peripherals\n"); |
2921 | goto probe_err4; | 2917 | goto probe_err2; |
2922 | } | 2918 | } |
2923 | 2919 | ||
2924 | for (i = 0; i < num_chan; i++) { | 2920 | for (i = 0; i < num_chan; i++) { |
@@ -2962,7 +2958,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2962 | ret = dma_async_device_register(pd); | 2958 | ret = dma_async_device_register(pd); |
2963 | if (ret) { | 2959 | if (ret) { |
2964 | dev_err(&adev->dev, "unable to register DMAC\n"); | 2960 | dev_err(&adev->dev, "unable to register DMAC\n"); |
2965 | goto probe_err4; | 2961 | goto probe_err2; |
2966 | } | 2962 | } |
2967 | 2963 | ||
2968 | dev_info(&adev->dev, | 2964 | dev_info(&adev->dev, |
@@ -2975,15 +2971,10 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2975 | 2971 | ||
2976 | return 0; | 2972 | return 0; |
2977 | 2973 | ||
2978 | probe_err4: | ||
2979 | pl330_del(pi); | ||
2980 | probe_err3: | ||
2981 | free_irq(irq, pi); | ||
2982 | probe_err2: | 2974 | probe_err2: |
2983 | iounmap(pi->base); | 2975 | pl330_del(pi); |
2984 | probe_err1: | 2976 | probe_err1: |
2985 | release_mem_region(res->start, resource_size(res)); | 2977 | free_irq(irq, pi); |
2986 | kfree(pdmac); | ||
2987 | 2978 | ||
2988 | return ret; | 2979 | return ret; |
2989 | } | 2980 | } |
@@ -2993,7 +2984,6 @@ static int __devexit pl330_remove(struct amba_device *adev) | |||
2993 | struct dma_pl330_dmac *pdmac = amba_get_drvdata(adev); | 2984 | struct dma_pl330_dmac *pdmac = amba_get_drvdata(adev); |
2994 | struct dma_pl330_chan *pch, *_p; | 2985 | struct dma_pl330_chan *pch, *_p; |
2995 | struct pl330_info *pi; | 2986 | struct pl330_info *pi; |
2996 | struct resource *res; | ||
2997 | int irq; | 2987 | int irq; |
2998 | 2988 | ||
2999 | if (!pdmac) | 2989 | if (!pdmac) |
@@ -3020,13 +3010,6 @@ static int __devexit pl330_remove(struct amba_device *adev) | |||
3020 | irq = adev->irq[0]; | 3010 | irq = adev->irq[0]; |
3021 | free_irq(irq, pi); | 3011 | free_irq(irq, pi); |
3022 | 3012 | ||
3023 | iounmap(pi->base); | ||
3024 | |||
3025 | res = &adev->res; | ||
3026 | release_mem_region(res->start, resource_size(res)); | ||
3027 | |||
3028 | kfree(pdmac); | ||
3029 | |||
3030 | return 0; | 3013 | return 0; |
3031 | } | 3014 | } |
3032 | 3015 | ||