diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-11-08 13:10:42 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-04-03 19:31:46 -0400 |
commit | 9834f81314b2a5b1bb3cd0d8f46e61528b60d580 (patch) | |
tree | 6fb62c450a3a6587b312d2f0542b4fe25af7767d /arch | |
parent | 0ef64986d69602ba8df933c62d0b6d6edfaf0557 (diff) |
ARM: omap: move dma channel allocation into plat-omap code
This really needs to be there, because otherwise the plat-omap code can
kfree() this data structure, and then re-use the pointer later.
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-omap1/dma.c | 17 | ||||
-rw-r--r-- | arch/arm/mach-omap2/dma.c | 7 | ||||
-rw-r--r-- | arch/arm/plat-omap/dma.c | 11 |
3 files changed, 10 insertions, 25 deletions
diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c index c979e3f88bbb..d170f7d0a6ac 100644 --- a/arch/arm/mach-omap1/dma.c +++ b/arch/arm/mach-omap1/dma.c | |||
@@ -325,17 +325,6 @@ static int __init omap1_system_dma_init(void) | |||
325 | d->dev_caps |= CLEAR_CSR_ON_READ; | 325 | d->dev_caps |= CLEAR_CSR_ON_READ; |
326 | d->dev_caps |= IS_WORD_16; | 326 | d->dev_caps |= IS_WORD_16; |
327 | 327 | ||
328 | |||
329 | d->chan = kzalloc(sizeof(struct omap_dma_lch) * | ||
330 | (d->lch_count), GFP_KERNEL); | ||
331 | if (!d->chan) { | ||
332 | dev_err(&pdev->dev, | ||
333 | "%s: Memory allocation failed for d->chan!\n", | ||
334 | __func__); | ||
335 | ret = -ENOMEM; | ||
336 | goto exit_release_d; | ||
337 | } | ||
338 | |||
339 | if (cpu_is_omap15xx()) | 328 | if (cpu_is_omap15xx()) |
340 | d->chan_count = 9; | 329 | d->chan_count = 9; |
341 | else if (cpu_is_omap16xx() || cpu_is_omap7xx()) { | 330 | else if (cpu_is_omap16xx() || cpu_is_omap7xx()) { |
@@ -359,14 +348,14 @@ static int __init omap1_system_dma_init(void) | |||
359 | if (ret) { | 348 | if (ret) { |
360 | dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n", | 349 | dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n", |
361 | __func__, pdev->name, pdev->id); | 350 | __func__, pdev->name, pdev->id); |
362 | goto exit_release_chan; | 351 | goto exit_release_d; |
363 | } | 352 | } |
364 | 353 | ||
365 | ret = platform_device_add(pdev); | 354 | ret = platform_device_add(pdev); |
366 | if (ret) { | 355 | if (ret) { |
367 | dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n", | 356 | dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n", |
368 | __func__, pdev->name, pdev->id); | 357 | __func__, pdev->name, pdev->id); |
369 | goto exit_release_chan; | 358 | goto exit_release_d; |
370 | } | 359 | } |
371 | 360 | ||
372 | dma_pdev = platform_device_register_full(&omap_dma_dev_info); | 361 | dma_pdev = platform_device_register_full(&omap_dma_dev_info); |
@@ -379,8 +368,6 @@ static int __init omap1_system_dma_init(void) | |||
379 | 368 | ||
380 | exit_release_pdev: | 369 | exit_release_pdev: |
381 | platform_device_del(pdev); | 370 | platform_device_del(pdev); |
382 | exit_release_chan: | ||
383 | kfree(d->chan); | ||
384 | exit_release_d: | 371 | exit_release_d: |
385 | kfree(d); | 372 | kfree(d); |
386 | exit_release_p: | 373 | exit_release_p: |
diff --git a/arch/arm/mach-omap2/dma.c b/arch/arm/mach-omap2/dma.c index 244ff5012aed..9f210d637354 100644 --- a/arch/arm/mach-omap2/dma.c +++ b/arch/arm/mach-omap2/dma.c | |||
@@ -251,13 +251,6 @@ static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused) | |||
251 | } | 251 | } |
252 | 252 | ||
253 | d = oh->dev_attr; | 253 | d = oh->dev_attr; |
254 | d->chan = kzalloc(sizeof(struct omap_dma_lch) * | ||
255 | (d->lch_count), GFP_KERNEL); | ||
256 | |||
257 | if (!d->chan) { | ||
258 | dev_err(&pdev->dev, "%s: kzalloc fail\n", __func__); | ||
259 | return -ENOMEM; | ||
260 | } | ||
261 | 254 | ||
262 | if (cpu_is_omap34xx() && (omap_type() != OMAP2_DEVICE_TYPE_GP)) | 255 | if (cpu_is_omap34xx() && (omap_type() != OMAP2_DEVICE_TYPE_GP)) |
263 | d->dev_caps |= HS_CHANNELS_RESERVED; | 256 | d->dev_caps |= HS_CHANNELS_RESERVED; |
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c index d4d9a5e62152..5f5b975887fc 100644 --- a/arch/arm/plat-omap/dma.c +++ b/arch/arm/plat-omap/dma.c | |||
@@ -2030,9 +2030,16 @@ static int omap_system_dma_probe(struct platform_device *pdev) | |||
2030 | 2030 | ||
2031 | dma_lch_count = d->lch_count; | 2031 | dma_lch_count = d->lch_count; |
2032 | dma_chan_count = dma_lch_count; | 2032 | dma_chan_count = dma_lch_count; |
2033 | dma_chan = d->chan; | ||
2034 | enable_1510_mode = d->dev_caps & ENABLE_1510_MODE; | 2033 | enable_1510_mode = d->dev_caps & ENABLE_1510_MODE; |
2035 | 2034 | ||
2035 | dma_chan = devm_kcalloc(&pdev->dev, dma_lch_count, | ||
2036 | sizeof(struct omap_dma_lch), GFP_KERNEL); | ||
2037 | if (!dma_chan) { | ||
2038 | dev_err(&pdev->dev, "%s: kzalloc fail\n", __func__); | ||
2039 | return -ENOMEM; | ||
2040 | } | ||
2041 | |||
2042 | |||
2036 | if (dma_omap2plus()) { | 2043 | if (dma_omap2plus()) { |
2037 | dma_linked_lch = kzalloc(sizeof(struct dma_link_info) * | 2044 | dma_linked_lch = kzalloc(sizeof(struct dma_link_info) * |
2038 | dma_lch_count, GFP_KERNEL); | 2045 | dma_lch_count, GFP_KERNEL); |
@@ -2117,7 +2124,6 @@ exit_dma_irq_fail: | |||
2117 | } | 2124 | } |
2118 | 2125 | ||
2119 | exit_dma_lch_fail: | 2126 | exit_dma_lch_fail: |
2120 | kfree(dma_chan); | ||
2121 | return ret; | 2127 | return ret; |
2122 | } | 2128 | } |
2123 | 2129 | ||
@@ -2137,7 +2143,6 @@ static int omap_system_dma_remove(struct platform_device *pdev) | |||
2137 | free_irq(dma_irq, (void *)(irq_rel + 1)); | 2143 | free_irq(dma_irq, (void *)(irq_rel + 1)); |
2138 | } | 2144 | } |
2139 | } | 2145 | } |
2140 | kfree(dma_chan); | ||
2141 | return 0; | 2146 | return 0; |
2142 | } | 2147 | } |
2143 | 2148 | ||