gpio: davinci: Handle return value of clk_prepare_enable
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Tue, 23 May 2017 09:18:57 +0000 (14:48 +0530)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 29 May 2017 08:37:40 +0000 (10:37 +0200)
clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-davinci.c

index ac173575d3f69b07b31231f75cae8d721299addb..65cb359308e3fd110d3c986c19b8b3f9997fdf2b 100644 (file)
@@ -437,6 +437,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
 {
        unsigned        gpio, bank;
        int             irq;
+       int             ret;
        struct clk      *clk;
        u32             binten = 0;
        unsigned        ngpio, bank_irq;
@@ -480,12 +481,15 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
                       PTR_ERR(clk));
                return PTR_ERR(clk);
        }
-       clk_prepare_enable(clk);
+       ret = clk_prepare_enable(clk);
+       if (ret)
+               return ret;
 
        if (!pdata->gpio_unbanked) {
                irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0);
                if (irq < 0) {
                        dev_err(dev, "Couldn't allocate IRQ numbers\n");
+                       clk_disable_unprepare(clk);
                        return irq;
                }
 
@@ -494,6 +498,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
                                                        chips);
                if (!irq_domain) {
                        dev_err(dev, "Couldn't register an IRQ domain\n");
+                       clk_disable_unprepare(clk);
                        return -ENODEV;
                }
        }
@@ -562,8 +567,10 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
                                       sizeof(struct
                                              davinci_gpio_irq_data),
                                              GFP_KERNEL);
-               if (!irqdata)
+               if (!irqdata) {
+                       clk_disable_unprepare(clk);
                        return -ENOMEM;
+               }
 
                irqdata->regs = g;
                irqdata->bank_num = bank;