diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2016-07-20 04:50:29 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2016-08-10 13:29:12 -0400 |
commit | 2d1a9a946faebfedd660a1f1c2b90984fff41f91 (patch) | |
tree | 3cdb93e68802191edc1f42995e1df9a5d791bf10 | |
parent | b57ebe080cffb323b062fbff1a35ef59de3bd5d1 (diff) |
dmaengine: omap-dma: Dynamically allocate memory for lch_map
On OMAP1 platforms we do not have 32 channels available. Allocate the
lch_map based on the available channels. This way we are not going to have
more visible channels then it is available on the platform.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r-- | drivers/dma/omap-dma.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index 3c445942bd31..774306d372c9 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/omap-dma.c | |||
@@ -35,7 +35,7 @@ struct omap_dmadev { | |||
35 | unsigned dma_requests; | 35 | unsigned dma_requests; |
36 | spinlock_t irq_lock; | 36 | spinlock_t irq_lock; |
37 | uint32_t irq_enable_mask; | 37 | uint32_t irq_enable_mask; |
38 | struct omap_chan *lch_map[OMAP_SDMA_CHANNELS]; | 38 | struct omap_chan **lch_map; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | struct omap_chan { | 41 | struct omap_chan { |
@@ -1223,16 +1223,24 @@ static int omap_dma_probe(struct platform_device *pdev) | |||
1223 | spin_lock_init(&od->lock); | 1223 | spin_lock_init(&od->lock); |
1224 | spin_lock_init(&od->irq_lock); | 1224 | spin_lock_init(&od->irq_lock); |
1225 | 1225 | ||
1226 | od->dma_requests = OMAP_SDMA_REQUESTS; | 1226 | if (!pdev->dev.of_node) { |
1227 | if (pdev->dev.of_node && of_property_read_u32(pdev->dev.of_node, | 1227 | od->dma_requests = od->plat->dma_attr->lch_count; |
1228 | "dma-requests", | 1228 | if (unlikely(!od->dma_requests)) |
1229 | &od->dma_requests)) { | 1229 | od->dma_requests = OMAP_SDMA_REQUESTS; |
1230 | } else if (of_property_read_u32(pdev->dev.of_node, "dma-requests", | ||
1231 | &od->dma_requests)) { | ||
1230 | dev_info(&pdev->dev, | 1232 | dev_info(&pdev->dev, |
1231 | "Missing dma-requests property, using %u.\n", | 1233 | "Missing dma-requests property, using %u.\n", |
1232 | OMAP_SDMA_REQUESTS); | 1234 | OMAP_SDMA_REQUESTS); |
1235 | od->dma_requests = OMAP_SDMA_REQUESTS; | ||
1233 | } | 1236 | } |
1234 | 1237 | ||
1235 | for (i = 0; i < OMAP_SDMA_CHANNELS; i++) { | 1238 | od->lch_map = devm_kcalloc(&pdev->dev, od->dma_requests, |
1239 | sizeof(*od->lch_map), GFP_KERNEL); | ||
1240 | if (!od->lch_map) | ||
1241 | return -ENOMEM; | ||
1242 | |||
1243 | for (i = 0; i < od->dma_requests; i++) { | ||
1236 | rc = omap_dma_chan_init(od); | 1244 | rc = omap_dma_chan_init(od); |
1237 | if (rc) { | 1245 | if (rc) { |
1238 | omap_dma_free(od); | 1246 | omap_dma_free(od); |