diff options
author | Ian Molton <spyro@f2s.com> | 2008-07-25 17:59:29 -0400 |
---|---|---|
committer | Samuel Ortiz <samuel@sortiz.org> | 2008-10-19 16:54:09 -0400 |
commit | a87903f3b4fdbb2088d50a12eef872a1b3fa2ba4 (patch) | |
tree | 4bf292c607ed026110939f8d3380755a9d7ba415 /drivers | |
parent | 0cfd81031a26717fe14380d18275f8e217571615 (diff) |
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')
-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 9c9c126ed334..6c0d1bec4b76 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, | |||
20 | struct resource *mem_base, | 20 | struct resource *mem_base, |
21 | int irq_base) | 21 | int irq_base) |
22 | { | 22 | { |
23 | struct resource res[cell->num_resources]; | 23 | struct resource *res; |
24 | struct platform_device *pdev; | 24 | struct platform_device *pdev; |
25 | int ret = -ENOMEM; | 25 | int ret = -ENOMEM; |
26 | int r; | 26 | int r; |
@@ -29,14 +29,17 @@ static int mfd_add_device(struct device *parent, int id, | |||
29 | if (!pdev) | 29 | if (!pdev) |
30 | goto fail_alloc; | 30 | goto fail_alloc; |
31 | 31 | ||
32 | res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL); | ||
33 | if (!res) | ||
34 | goto fail_device; | ||
35 | |||
32 | pdev->dev.parent = parent; | 36 | pdev->dev.parent = parent; |
33 | 37 | ||
34 | ret = platform_device_add_data(pdev, | 38 | ret = platform_device_add_data(pdev, |
35 | cell->platform_data, cell->data_size); | 39 | cell->platform_data, cell->data_size); |
36 | if (ret) | 40 | if (ret) |
37 | goto fail_device; | 41 | goto fail_res; |
38 | 42 | ||
39 | memset(res, 0, sizeof(res)); | ||
40 | for (r = 0; r < cell->num_resources; r++) { | 43 | for (r = 0; r < cell->num_resources; r++) { |
41 | res[r].name = cell->resources[r].name; | 44 | res[r].name = cell->resources[r].name; |
42 | res[r].flags = cell->resources[r].flags; | 45 | res[r].flags = cell->resources[r].flags; |
@@ -64,11 +67,15 @@ static int mfd_add_device(struct device *parent, int id, | |||
64 | 67 | ||
65 | ret = platform_device_add(pdev); | 68 | ret = platform_device_add(pdev); |
66 | if (ret) | 69 | if (ret) |
67 | goto fail_device; | 70 | goto fail_res; |
71 | |||
72 | kfree(res); | ||
68 | 73 | ||
69 | return 0; | 74 | return 0; |
70 | 75 | ||
71 | /* platform_device_del(pdev); */ | 76 | /* platform_device_del(pdev); */ |
77 | fail_res: | ||
78 | kfree(res); | ||
72 | fail_device: | 79 | fail_device: |
73 | platform_device_put(pdev); | 80 | platform_device_put(pdev); |
74 | fail_alloc: | 81 | fail_alloc: |