mvebu: backport mainline patches from kernel 3.12
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0103-mtd-nand-pxa3xx-Use-devm_clk_get.patch
1 From 4ff9eea8b6841bb8be7becba9713a0ce7c82da9d Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Wed, 17 Apr 2013 13:38:11 -0300
4 Subject: [PATCH 103/203] mtd: nand: pxa3xx: Use devm_clk_get
5
6 Replacing clk_get by managed devm_clk_get, the error path
7 can be greatly simplified.
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 | 16 +++++++---------
14  1 file changed, 7 insertions(+), 9 deletions(-)
15
16 --- a/drivers/mtd/nand/pxa3xx_nand.c
17 +++ b/drivers/mtd/nand/pxa3xx_nand.c
18 @@ -1067,7 +1067,7 @@ static int alloc_nand_resource(struct pl
19  
20         spin_lock_init(&chip->controller->lock);
21         init_waitqueue_head(&chip->controller->wq);
22 -       info->clk = clk_get(&pdev->dev, NULL);
23 +       info->clk = devm_clk_get(&pdev->dev, NULL);
24         if (IS_ERR(info->clk)) {
25                 dev_err(&pdev->dev, "failed to get nand clock\n");
26                 return PTR_ERR(info->clk);
27 @@ -1087,7 +1087,7 @@ static int alloc_nand_resource(struct pl
28                 if (r == NULL) {
29                         dev_err(&pdev->dev, "no resource defined for data DMA\n");
30                         ret = -ENXIO;
31 -                       goto fail_put_clk;
32 +                       goto fail_disable_clk;
33                 }
34                 info->drcmr_dat = r->start;
35  
36 @@ -1095,7 +1095,7 @@ static int alloc_nand_resource(struct pl
37                 if (r == NULL) {
38                         dev_err(&pdev->dev, "no resource defined for command DMA\n");
39                         ret = -ENXIO;
40 -                       goto fail_put_clk;
41 +                       goto fail_disable_clk;
42                 }
43                 info->drcmr_cmd = r->start;
44         }
45 @@ -1104,20 +1104,20 @@ static int alloc_nand_resource(struct pl
46         if (irq < 0) {
47                 dev_err(&pdev->dev, "no IRQ resource defined\n");
48                 ret = -ENXIO;
49 -               goto fail_put_clk;
50 +               goto fail_disable_clk;
51         }
52  
53         r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
54         info->mmio_base = devm_ioremap_resource(&pdev->dev, r);
55         if (IS_ERR(info->mmio_base)) {
56                 ret = PTR_ERR(info->mmio_base);
57 -               goto fail_put_clk;
58 +               goto fail_disable_clk;
59         }
60         info->mmio_phys = r->start;
61  
62         ret = pxa3xx_nand_init_buff(info);
63         if (ret)
64 -               goto fail_put_clk;
65 +               goto fail_disable_clk;
66  
67         /* initialize all interrupts to be disabled */
68         disable_int(info, NDSR_MASK);
69 @@ -1141,9 +1141,8 @@ fail_free_buf:
70                         info->data_buff, info->data_buff_phys);
71         } else
72                 kfree(info->data_buff);
73 -fail_put_clk:
74 +fail_disable_clk:
75         clk_disable(info->clk);
76 -       clk_put(info->clk);
77         return ret;
78  }
79  
80 @@ -1170,7 +1169,6 @@ static int pxa3xx_nand_remove(struct pla
81                 kfree(info->data_buff);
82  
83         clk_disable(info->clk);
84 -       clk_put(info->clk);
85  
86         for (cs = 0; cs < pdata->num_cs; cs++)
87                 nand_release(info->host[cs]->mtd);