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>
This commit is contained in:
Родитель
0cfd81031a
Коммит
a87903f3b4
|
@ -20,7 +20,7 @@ static int mfd_add_device(struct device *parent, int id,
|
||||||
struct resource *mem_base,
|
struct resource *mem_base,
|
||||||
int irq_base)
|
int irq_base)
|
||||||
{
|
{
|
||||||
struct resource res[cell->num_resources];
|
struct resource *res;
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
int r;
|
int r;
|
||||||
|
@ -29,14 +29,17 @@ static int mfd_add_device(struct device *parent, int id,
|
||||||
if (!pdev)
|
if (!pdev)
|
||||||
goto fail_alloc;
|
goto fail_alloc;
|
||||||
|
|
||||||
|
res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL);
|
||||||
|
if (!res)
|
||||||
|
goto fail_device;
|
||||||
|
|
||||||
pdev->dev.parent = parent;
|
pdev->dev.parent = parent;
|
||||||
|
|
||||||
ret = platform_device_add_data(pdev,
|
ret = platform_device_add_data(pdev,
|
||||||
cell->platform_data, cell->data_size);
|
cell->platform_data, cell->data_size);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail_device;
|
goto fail_res;
|
||||||
|
|
||||||
memset(res, 0, sizeof(res));
|
|
||||||
for (r = 0; r < cell->num_resources; r++) {
|
for (r = 0; r < cell->num_resources; r++) {
|
||||||
res[r].name = cell->resources[r].name;
|
res[r].name = cell->resources[r].name;
|
||||||
res[r].flags = cell->resources[r].flags;
|
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);
|
ret = platform_device_add(pdev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail_device;
|
goto fail_res;
|
||||||
|
|
||||||
|
kfree(res);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* platform_device_del(pdev); */
|
/* platform_device_del(pdev); */
|
||||||
|
fail_res:
|
||||||
|
kfree(res);
|
||||||
fail_device:
|
fail_device:
|
||||||
platform_device_put(pdev);
|
platform_device_put(pdev);
|
||||||
fail_alloc:
|
fail_alloc:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче