Commit 34a378fc authored by Russell King's avatar Russell King

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: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 9834f813
...@@ -263,9 +263,17 @@ static const struct platform_device_info omap_dma_dev_info = { ...@@ -263,9 +263,17 @@ static const struct platform_device_info omap_dma_dev_info = {
.dma_mask = DMA_BIT_MASK(32), .dma_mask = DMA_BIT_MASK(32),
}; };
static struct omap_system_dma_plat_info dma_plat_info __initdata = {
.show_dma_caps = omap1_show_dma_caps,
.clear_lch_regs = omap1_clear_lch_regs,
.clear_dma = omap1_clear_dma,
.dma_write = dma_write,
.dma_read = dma_read,
};
static int __init omap1_system_dma_init(void) static int __init omap1_system_dma_init(void)
{ {
struct omap_system_dma_plat_info *p; struct omap_system_dma_plat_info p;
struct omap_dma_dev_attr *d; struct omap_dma_dev_attr *d;
struct platform_device *pdev, *dma_pdev; struct platform_device *pdev, *dma_pdev;
int ret; int ret;
...@@ -291,20 +299,12 @@ static int __init omap1_system_dma_init(void) ...@@ -291,20 +299,12 @@ static int __init omap1_system_dma_init(void)
goto exit_iounmap; goto exit_iounmap;
} }
p = kzalloc(sizeof(struct omap_system_dma_plat_info), GFP_KERNEL);
if (!p) {
dev_err(&pdev->dev, "%s: Unable to allocate 'p' for %s\n",
__func__, pdev->name);
ret = -ENOMEM;
goto exit_iounmap;
}
d = kzalloc(sizeof(struct omap_dma_dev_attr), GFP_KERNEL); d = kzalloc(sizeof(struct omap_dma_dev_attr), GFP_KERNEL);
if (!d) { if (!d) {
dev_err(&pdev->dev, "%s: Unable to allocate 'd' for %s\n", dev_err(&pdev->dev, "%s: Unable to allocate 'd' for %s\n",
__func__, pdev->name); __func__, pdev->name);
ret = -ENOMEM; ret = -ENOMEM;
goto exit_release_p; goto exit_iounmap;
} }
d->lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; d->lch_count = OMAP1_LOGICAL_DMA_CH_COUNT;
...@@ -334,17 +334,11 @@ static int __init omap1_system_dma_init(void) ...@@ -334,17 +334,11 @@ static int __init omap1_system_dma_init(void)
d->chan_count = 9; d->chan_count = 9;
} }
p->dma_attr = d; p = dma_plat_info;
p.dma_attr = d;
p->show_dma_caps = omap1_show_dma_caps; p.errata = configure_dma_errata();
p->clear_lch_regs = omap1_clear_lch_regs;
p->clear_dma = omap1_clear_dma;
p->dma_write = dma_write;
p->dma_read = dma_read;
p->errata = configure_dma_errata();
ret = platform_device_add_data(pdev, p, sizeof(*p)); ret = platform_device_add_data(pdev, &p, sizeof(p));
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n", dev_err(&pdev->dev, "%s: Unable to add resources for %s%d\n",
__func__, pdev->name, pdev->id); __func__, pdev->name, pdev->id);
...@@ -370,8 +364,6 @@ static int __init omap1_system_dma_init(void) ...@@ -370,8 +364,6 @@ static int __init omap1_system_dma_init(void)
platform_device_del(pdev); platform_device_del(pdev);
exit_release_d: exit_release_d:
kfree(d); kfree(d);
exit_release_p:
kfree(p);
exit_iounmap: exit_iounmap:
iounmap(dma_base); iounmap(dma_base);
exit_device_put: exit_device_put:
......
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include "omap_hwmod.h" #include "omap_hwmod.h"
#include "omap_device.h" #include "omap_device.h"
static struct omap_dma_dev_attr *d;
static enum omap_reg_offsets dma_common_ch_end; static enum omap_reg_offsets dma_common_ch_end;
static const struct omap_dma_reg reg_map[] = { static const struct omap_dma_reg reg_map[] = {
...@@ -206,33 +204,27 @@ static unsigned configure_dma_errata(void) ...@@ -206,33 +204,27 @@ static unsigned configure_dma_errata(void)
return errata; return errata;
} }
static struct omap_system_dma_plat_info dma_plat_info __initdata = {
.show_dma_caps = omap2_show_dma_caps,
.clear_dma = omap2_clear_dma,
.dma_write = dma_write,
.dma_read = dma_read,
};
/* One time initializations */ /* One time initializations */
static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused) static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused)
{ {
struct platform_device *pdev; struct platform_device *pdev;
struct omap_system_dma_plat_info *p; struct omap_system_dma_plat_info p;
struct omap_dma_dev_attr *d;
struct resource *mem; struct resource *mem;
char *name = "omap_dma_system"; char *name = "omap_dma_system";
p = kzalloc(sizeof(struct omap_system_dma_plat_info), GFP_KERNEL); p = dma_plat_info;
if (!p) { p.dma_attr = (struct omap_dma_dev_attr *)oh->dev_attr;
pr_err("%s: Unable to allocate pdata for %s:%s\n", p.errata = configure_dma_errata();
__func__, name, oh->name);
return -ENOMEM;
}
p->dma_attr = (struct omap_dma_dev_attr *)oh->dev_attr;
p->show_dma_caps = omap2_show_dma_caps;
p->clear_dma = omap2_clear_dma;
p->dma_write = dma_write;
p->dma_read = dma_read;
p->clear_lch_regs = NULL;
p->errata = configure_dma_errata();
pdev = omap_device_build(name, 0, oh, p, sizeof(*p)); pdev = omap_device_build(name, 0, oh, &p, sizeof(p));
kfree(p);
if (IS_ERR(pdev)) { if (IS_ERR(pdev)) {
pr_err("%s: Can't build omap_device for %s:%s.\n", pr_err("%s: Can't build omap_device for %s:%s.\n",
__func__, name, oh->name); __func__, name, oh->name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment