1 From 271ef48cf11b86ab666582051fed3bdb13681e64 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Wed, 17 Apr 2013 13:38:09 -0300
4 Subject: [PATCH 101/203] mtd: nand: pxa3xx: Use devm_kzalloc
6 Replace regular kzalloc with managed devm_kzalloc
7 which simplifies the error path.
9 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
10 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
11 Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
13 drivers/mtd/nand/pxa3xx_nand.c | 14 ++++----------
14 1 file changed, 4 insertions(+), 10 deletions(-)
16 --- a/drivers/mtd/nand/pxa3xx_nand.c
17 +++ b/drivers/mtd/nand/pxa3xx_nand.c
18 @@ -1035,12 +1035,10 @@ static int alloc_nand_resource(struct pl
21 pdata = pdev->dev.platform_data;
22 - info = kzalloc(sizeof(*info) + (sizeof(*mtd) +
23 - sizeof(*host)) * pdata->num_cs, GFP_KERNEL);
25 - dev_err(&pdev->dev, "failed to allocate memory\n");
26 + info = devm_kzalloc(&pdev->dev, sizeof(*info) + (sizeof(*mtd) +
27 + sizeof(*host)) * pdata->num_cs, GFP_KERNEL);
33 for (cs = 0; cs < pdata->num_cs; cs++) {
34 @@ -1072,8 +1070,7 @@ static int alloc_nand_resource(struct pl
35 info->clk = clk_get(&pdev->dev, NULL);
36 if (IS_ERR(info->clk)) {
37 dev_err(&pdev->dev, "failed to get nand clock\n");
38 - ret = PTR_ERR(info->clk);
40 + return PTR_ERR(info->clk);
42 clk_enable(info->clk);
44 @@ -1165,8 +1162,6 @@ fail_free_res:
46 clk_disable(info->clk);
53 @@ -1202,7 +1197,6 @@ static int pxa3xx_nand_remove(struct pla
55 for (cs = 0; cs < pdata->num_cs; cs++)
56 nand_release(info->host[cs]->mtd);