diff options
author | Padmavathi Venna <padma.v@samsung.com> | 2013-03-05 04:25:31 -0500 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-04-02 13:41:04 -0400 |
commit | 0b94c57717054811dd836d582585d3fb4856b43f (patch) | |
tree | 1fb8bc2f94d795271c091d02f6e5e0678656d0e2 | |
parent | 07961ac7c0ee8b546658717034fe692fd12eefa9 (diff) |
DMA: PL330: Add check if device tree compatible
This patch register the dma controller with generic dma helpers only
in DT case. This also adds some extra error handling in the driver.
Signed-off-by: Padmavathi Venna <padma.v@samsung.com>
Reported-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r-- | drivers/dma/pl330.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 718153122759..5dbc5946c4c3 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
@@ -2882,7 +2882,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2882 | { | 2882 | { |
2883 | struct dma_pl330_platdata *pdat; | 2883 | struct dma_pl330_platdata *pdat; |
2884 | struct dma_pl330_dmac *pdmac; | 2884 | struct dma_pl330_dmac *pdmac; |
2885 | struct dma_pl330_chan *pch; | 2885 | struct dma_pl330_chan *pch, *_p; |
2886 | struct pl330_info *pi; | 2886 | struct pl330_info *pi; |
2887 | struct dma_device *pd; | 2887 | struct dma_device *pd; |
2888 | struct resource *res; | 2888 | struct resource *res; |
@@ -2984,7 +2984,16 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2984 | ret = dma_async_device_register(pd); | 2984 | ret = dma_async_device_register(pd); |
2985 | if (ret) { | 2985 | if (ret) { |
2986 | dev_err(&adev->dev, "unable to register DMAC\n"); | 2986 | dev_err(&adev->dev, "unable to register DMAC\n"); |
2987 | goto probe_err2; | 2987 | goto probe_err3; |
2988 | } | ||
2989 | |||
2990 | if (adev->dev.of_node) { | ||
2991 | ret = of_dma_controller_register(adev->dev.of_node, | ||
2992 | of_dma_pl330_xlate, pdmac); | ||
2993 | if (ret) { | ||
2994 | dev_err(&adev->dev, | ||
2995 | "unable to register DMA to the generic DT DMA helpers\n"); | ||
2996 | } | ||
2988 | } | 2997 | } |
2989 | 2998 | ||
2990 | dev_info(&adev->dev, | 2999 | dev_info(&adev->dev, |
@@ -2995,16 +3004,21 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
2995 | pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan, | 3004 | pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan, |
2996 | pi->pcfg.num_peri, pi->pcfg.num_events); | 3005 | pi->pcfg.num_peri, pi->pcfg.num_events); |
2997 | 3006 | ||
2998 | ret = of_dma_controller_register(adev->dev.of_node, | ||
2999 | of_dma_pl330_xlate, pdmac); | ||
3000 | if (ret) { | ||
3001 | dev_err(&adev->dev, | ||
3002 | "unable to register DMA to the generic DT DMA helpers\n"); | ||
3003 | goto probe_err2; | ||
3004 | } | ||
3005 | |||
3006 | return 0; | 3007 | return 0; |
3008 | probe_err3: | ||
3009 | amba_set_drvdata(adev, NULL); | ||
3007 | 3010 | ||
3011 | /* Idle the DMAC */ | ||
3012 | list_for_each_entry_safe(pch, _p, &pdmac->ddma.channels, | ||
3013 | chan.device_node) { | ||
3014 | |||
3015 | /* Remove the channel */ | ||
3016 | list_del(&pch->chan.device_node); | ||
3017 | |||
3018 | /* Flush the channel */ | ||
3019 | pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0); | ||
3020 | pl330_free_chan_resources(&pch->chan); | ||
3021 | } | ||
3008 | probe_err2: | 3022 | probe_err2: |
3009 | pl330_del(pi); | 3023 | pl330_del(pi); |
3010 | probe_err1: | 3024 | probe_err1: |
@@ -3023,8 +3037,10 @@ static int pl330_remove(struct amba_device *adev) | |||
3023 | if (!pdmac) | 3037 | if (!pdmac) |
3024 | return 0; | 3038 | return 0; |
3025 | 3039 | ||
3026 | of_dma_controller_free(adev->dev.of_node); | 3040 | if (adev->dev.of_node) |
3041 | of_dma_controller_free(adev->dev.of_node); | ||
3027 | 3042 | ||
3043 | dma_async_device_unregister(&pdmac->ddma); | ||
3028 | amba_set_drvdata(adev, NULL); | 3044 | amba_set_drvdata(adev, NULL); |
3029 | 3045 | ||
3030 | /* Idle the DMAC */ | 3046 | /* Idle the DMAC */ |