diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-11-08 13:21:35 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-04-03 19:31:47 -0400 |
commit | 34a378fcb9273d73dbd6b209952d2f6bf88a3dd0 (patch) | |
tree | b53e2def902af95a291603dd8a1b2d00a45b7719 | |
parent | 9834f81314b2a5b1bb3cd0d8f46e61528b60d580 (diff) |
ARM: omap: dma: get rid of 'p' allocation and clean up
The omap_system_dma_plat_info structure is only seven words, it's not
worth the expense of kmalloc()'ing backing store for this only to
release it later. Note that platform_device_add_data() copies the
data anyway. Clean up the initialisation of this structure - we don't
even need code to initialise most of this structure.
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/mach-omap1/dma.c | 36 | ||||
-rw-r--r-- | arch/arm/mach-omap2/dma.c | 34 |
2 files changed, 27 insertions, 43 deletions
diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c index d170f7d0a6ac..a8c83ccc36fb 100644 --- a/arch/arm/mach-omap1/dma.c +++ b/arch/arm/mach-omap1/dma.c | |||
@@ -263,9 +263,17 @@ static const struct platform_device_info omap_dma_dev_info = { | |||
263 | .dma_mask = DMA_BIT_MASK(32), | 263 | .dma_mask = DMA_BIT_MASK(32), |
264 | }; | 264 | }; |
265 | 265 | ||
266 | static struct omap_system_dma_plat_info dma_plat_info __initdata = { | ||
267 | .show_dma_caps = omap1_show_dma_caps, | ||
268 | .clear_lch_regs = omap1_clear_lch_regs, | ||
269 | .clear_dma = omap1_clear_dma, | ||
270 | .dma_write = dma_write, | ||
271 | .dma_read = dma_read, | ||
272 | }; | ||
273 | |||
266 | static int __init omap1_system_dma_init(void) | 274 | static int __init omap1_system_dma_init(void) |
267 | { | 275 | { |
268 | struct omap_system_dma_plat_info *p; | 276 | struct omap_system_dma_plat_info p; |
269 | struct omap_dma_dev_attr *d; | 277 | struct omap_dma_dev_attr *d; |
270 | struct platform_device *pdev, *dma_pdev; | 278 | struct platform_device *pdev, *dma_pdev; |
271 | int ret; | 279 | int ret; |
@@ -291,20 +299,12 @@ static int __init omap1_system_dma_init(void) | |||
291 | goto exit_iounmap; | 299 | goto exit_iounmap; |
292 | } | 300 | } |
293 | 301 | ||
294 | p = kzalloc(sizeof(struct omap_system_dma_plat_info), GFP_KERNEL); | ||
295 | if (!p) { | ||
296 | dev_err(&pdev->dev, "%s: Unable to allocate 'p' for %s\n", | ||
297 | __func__, pdev->name); | ||
298 | ret = -ENOMEM; | ||
299 | goto exit_iounmap; | ||
300 | } | ||
301 | |||
302 | d = kzalloc(sizeof(struct omap_dma_dev_attr), GFP_KERNEL); | 302 | d = kzalloc(sizeof(struct omap_dma_dev_attr), GFP_KERNEL); |
303 | if (!d) { | 303 | if (!d) { |
304 | dev_err(&pdev->dev, "%s: Unable to allocate 'd' for %s\n", | 304 | dev_err(&pdev->dev, "%s: Unable to allocate 'd' for %s\n", |
305 | __func__, pdev->name); | 305 | __func__, pdev->name); |
306 | ret = -ENOMEM; | 306 | ret = -ENOMEM; |
307 | goto exit_release_p; | 307 | goto exit_iounmap; |
308 | } | 308 | } |
309 | 309 | ||
310 | d->lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; | 310 | d->lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; |
@@ -334,17 +334,11 @@ static int __init omap1_system_dma_init(void) | |||
334 | d->chan_count = 9; | 334 | d->chan_count = 9; |
335 | } | 335 | } |
336 | 336 | ||
337 | p->dma_attr = d; | 337 | p = dma_plat_info; |
338 | 338 | p.dma_attr = d; | |
339 | p->show_dma_caps = omap1_show_dma_caps; | 339 | p.errata = configure_dma_errata(); |
340 | p->clear_lch_regs = omap1_clear_lch_regs; | ||
341 | p->clear_dma = omap1_clear_dma; | ||
342 | p->dma_write = dma_write; | ||
343 | p->dma_read = dma_read; | ||
344 | |||
345 | p->errata = configure_dma_errata(); | ||
346 | 340 | ||
347 | ret = platform_device_add_data(pdev, p, sizeof(*p)); | 341 | ret = platform_device_add_data(pdev, &p, sizeof(p)); |
348 | if (ret) { | 342 | if (ret) { |
349 | dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n", | 343 | dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n", |
350 | __func__, pdev->name, pdev->id); | 344 | __func__, pdev->name, pdev->id); |
@@ -370,8 +364,6 @@ exit_release_pdev: | |||
370 | platform_device_del(pdev); | 364 | platform_device_del(pdev); |
371 | exit_release_d: | 365 | exit_release_d: |
372 | kfree(d); | 366 | kfree(d); |
373 | exit_release_p: | ||
374 | kfree(p); | ||
375 | exit_iounmap: | 367 | exit_iounmap: |
376 | iounmap(dma_base); | 368 | iounmap(dma_base); |
377 | exit_device_put: | 369 | exit_device_put: |
diff --git a/arch/arm/mach-omap2/dma.c b/arch/arm/mach-omap2/dma.c index 9f210d637354..6331fc4b4054 100644 --- a/arch/arm/mach-omap2/dma.c +++ b/arch/arm/mach-omap2/dma.c | |||
@@ -35,8 +35,6 @@ | |||
35 | #include "omap_hwmod.h" | 35 | #include "omap_hwmod.h" |
36 | #include "omap_device.h" | 36 | #include "omap_device.h" |
37 | 37 | ||
38 | static struct omap_dma_dev_attr *d; | ||
39 | |||
40 | static enum omap_reg_offsets dma_common_ch_end; | 38 | static enum omap_reg_offsets dma_common_ch_end; |
41 | 39 | ||
42 | static const struct omap_dma_reg reg_map[] = { | 40 | static const struct omap_dma_reg reg_map[] = { |
@@ -206,33 +204,27 @@ static unsigned configure_dma_errata(void) | |||
206 | return errata; | 204 | return errata; |
207 | } | 205 | } |
208 | 206 | ||
207 | static struct omap_system_dma_plat_info dma_plat_info __initdata = { | ||
208 | .show_dma_caps = omap2_show_dma_caps, | ||
209 | .clear_dma = omap2_clear_dma, | ||
210 | .dma_write = dma_write, | ||
211 | .dma_read = dma_read, | ||
212 | }; | ||
213 | |||
209 | /* One time initializations */ | 214 | /* One time initializations */ |
210 | static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused) | 215 | static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused) |
211 | { | 216 | { |
212 | struct platform_device *pdev; | 217 | struct platform_device *pdev; |
213 | struct omap_system_dma_plat_info *p; | 218 | struct omap_system_dma_plat_info p; |
219 | struct omap_dma_dev_attr *d; | ||
214 | struct resource *mem; | 220 | struct resource *mem; |
215 | char *name = "omap_dma_system"; | 221 | char *name = "omap_dma_system"; |
216 | 222 | ||
217 | p = kzalloc(sizeof(struct omap_system_dma_plat_info), GFP_KERNEL); | 223 | p = dma_plat_info; |
218 | if (!p) { | 224 | p.dma_attr = (struct omap_dma_dev_attr *)oh->dev_attr; |
219 | pr_err("%s: Unable to allocate pdata for %s:%s\n", | 225 | p.errata = configure_dma_errata(); |
220 | __func__, name, oh->name); | ||
221 | return -ENOMEM; | ||
222 | } | ||
223 | |||
224 | p->dma_attr = (struct omap_dma_dev_attr *)oh->dev_attr; | ||
225 | p->show_dma_caps = omap2_show_dma_caps; | ||
226 | p->clear_dma = omap2_clear_dma; | ||
227 | p->dma_write = dma_write; | ||
228 | p->dma_read = dma_read; | ||
229 | |||
230 | p->clear_lch_regs = NULL; | ||
231 | |||
232 | p->errata = configure_dma_errata(); | ||
233 | 226 | ||
234 | pdev = omap_device_build(name, 0, oh, p, sizeof(*p)); | 227 | pdev = omap_device_build(name, 0, oh, &p, sizeof(p)); |
235 | kfree(p); | ||
236 | if (IS_ERR(pdev)) { | 228 | if (IS_ERR(pdev)) { |
237 | pr_err("%s: Can't build omap_device for %s:%s.\n", | 229 | pr_err("%s: Can't build omap_device for %s:%s.\n", |
238 | __func__, name, oh->name); | 230 | __func__, name, oh->name); |