base-files: define yes/no as valid boolean options
[openwrt/staging/wigyori.git] / target / linux / mvebu / patches-3.10 / 0101-mtd-nand-pxa3xx-Use-devm_kzalloc.patch
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
5
6 Replace regular kzalloc with managed devm_kzalloc
7 which simplifies the error path.
8
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>
12 ---
13 drivers/mtd/nand/pxa3xx_nand.c | 14 ++++----------
14 1 file changed, 4 insertions(+), 10 deletions(-)
15
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
19 int ret, irq, cs;
20
21 pdata = pdev->dev.platform_data;
22 - info = kzalloc(sizeof(*info) + (sizeof(*mtd) +
23 - sizeof(*host)) * pdata->num_cs, GFP_KERNEL);
24 - if (!info) {
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);
28 + if (!info)
29 return -ENOMEM;
30 - }
31
32 info->pdev = pdev;
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);
39 - goto fail_free_mtd;
40 + return PTR_ERR(info->clk);
41 }
42 clk_enable(info->clk);
43
44 @@ -1165,8 +1162,6 @@ fail_free_res:
45 fail_put_clk:
46 clk_disable(info->clk);
47 clk_put(info->clk);
48 -fail_free_mtd:
49 - kfree(info);
50 return ret;
51 }
52
53 @@ -1202,7 +1197,6 @@ static int pxa3xx_nand_remove(struct pla
54
55 for (cs = 0; cs < pdata->num_cs; cs++)
56 nand_release(info->host[cs]->mtd);
57 - kfree(info);
58 return 0;
59 }
60