Commit 4c073cd2 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by David Woodhouse

mtd: nand: pxa3xx: Use devm_kzalloc

Replace regular kzalloc with managed devm_kzalloc
which simplifies the error path.
Signed-off-by: default avatarEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent a1c06609
...@@ -1035,12 +1035,10 @@ static int alloc_nand_resource(struct platform_device *pdev) ...@@ -1035,12 +1035,10 @@ static int alloc_nand_resource(struct platform_device *pdev)
int ret, irq, cs; int ret, irq, cs;
pdata = pdev->dev.platform_data; pdata = pdev->dev.platform_data;
info = kzalloc(sizeof(*info) + (sizeof(*mtd) + info = devm_kzalloc(&pdev->dev, sizeof(*info) + (sizeof(*mtd) +
sizeof(*host)) * pdata->num_cs, GFP_KERNEL); sizeof(*host)) * pdata->num_cs, GFP_KERNEL);
if (!info) { if (!info)
dev_err(&pdev->dev, "failed to allocate memory\n");
return -ENOMEM; return -ENOMEM;
}
info->pdev = pdev; info->pdev = pdev;
for (cs = 0; cs < pdata->num_cs; cs++) { for (cs = 0; cs < pdata->num_cs; cs++) {
...@@ -1072,8 +1070,7 @@ static int alloc_nand_resource(struct platform_device *pdev) ...@@ -1072,8 +1070,7 @@ static int alloc_nand_resource(struct platform_device *pdev)
info->clk = clk_get(&pdev->dev, NULL); info->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(info->clk)) { if (IS_ERR(info->clk)) {
dev_err(&pdev->dev, "failed to get nand clock\n"); dev_err(&pdev->dev, "failed to get nand clock\n");
ret = PTR_ERR(info->clk); return PTR_ERR(info->clk);
goto fail_free_mtd;
} }
clk_enable(info->clk); clk_enable(info->clk);
...@@ -1165,8 +1162,6 @@ static int alloc_nand_resource(struct platform_device *pdev) ...@@ -1165,8 +1162,6 @@ static int alloc_nand_resource(struct platform_device *pdev)
fail_put_clk: fail_put_clk:
clk_disable(info->clk); clk_disable(info->clk);
clk_put(info->clk); clk_put(info->clk);
fail_free_mtd:
kfree(info);
return ret; return ret;
} }
...@@ -1202,7 +1197,6 @@ static int pxa3xx_nand_remove(struct platform_device *pdev) ...@@ -1202,7 +1197,6 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
for (cs = 0; cs < pdata->num_cs; cs++) for (cs = 0; cs < pdata->num_cs; cs++)
nand_release(info->host[cs]->mtd); nand_release(info->host[cs]->mtd);
kfree(info);
return 0; return 0;
} }
......
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