diff options
author | Ian Molton <spyro@f2s.com> | 2008-07-25 22:59:29 +0100 |
---|---|---|
committer | Samuel Ortiz <samuel@sortiz.org> | 2008-10-19 22:54:09 +0200 |
commit | a87903f3b4fdbb2088d50a12eef872a1b3fa2ba4 (patch) | |
tree | 4bf292c607ed026110939f8d3380755a9d7ba415 /drivers/mfd/mfd-core.c | |
parent | 0cfd81031a26717fe14380d18275f8e217571615 (diff) | |
download | op-kernel-dev-a87903f3b4fdbb2088d50a12eef872a1b3fa2ba4.zip op-kernel-dev-a87903f3b4fdbb2088d50a12eef872a1b3fa2ba4.tar.gz |
mfd: reduce stack usage in mfd-core.c
This patch moves the allocation of the resources off the stack in
mfd_add_device().
Signed-off-by: Ian Molton <spyro@f2s.com>
Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
Diffstat (limited to 'drivers/mfd/mfd-core.c')
-rw-r--r-- | drivers/mfd/mfd-core.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 9c9c126..6c0d1be 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -20,7 +20,7 @@ static int mfd_add_device(struct device *parent, int id, struct resource *mem_base, int irq_base) { - struct resource res[cell->num_resources]; + struct resource *res; struct platform_device *pdev; int ret = -ENOMEM; int r; @@ -29,14 +29,17 @@ static int mfd_add_device(struct device *parent, int id, if (!pdev) goto fail_alloc; + res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL); + if (!res) + goto fail_device; + pdev->dev.parent = parent; ret = platform_device_add_data(pdev, cell->platform_data, cell->data_size); if (ret) - goto fail_device; + goto fail_res; - memset(res, 0, sizeof(res)); for (r = 0; r < cell->num_resources; r++) { res[r].name = cell->resources[r].name; res[r].flags = cell->resources[r].flags; @@ -64,11 +67,15 @@ static int mfd_add_device(struct device *parent, int id, ret = platform_device_add(pdev); if (ret) - goto fail_device; + goto fail_res; + + kfree(res); return 0; /* platform_device_del(pdev); */ +fail_res: + kfree(res); fail_device: platform_device_put(pdev); fail_alloc: |