]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
i2c: at91: Handle return value of clk_prepare_enable
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Wed, 31 May 2017 06:57:44 +0000 (12:27 +0530)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 19 Jun 2017 14:28:58 +0000 (16:28 +0200)
clk_prepare_enable() can fail here and we must check its return value.
Also, add a missing clk_disable_unprepare().

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-at91.c

index fabbb9e49161293c0f17ad8d8998ac016612a34b..2525cd9bcbbdd58c281ce823f3188ca052feea1e 100644 (file)
@@ -1083,12 +1083,16 @@ static int at91_twi_probe(struct platform_device *pdev)
                dev_err(dev->dev, "no clock defined\n");
                return -ENODEV;
        }
-       clk_prepare_enable(dev->clk);
+       rc = clk_prepare_enable(dev->clk);
+       if (rc)
+               return rc;
 
        if (dev->dev->of_node) {
                rc = at91_twi_configure_dma(dev, phy_addr);
-               if (rc == -EPROBE_DEFER)
+               if (rc == -EPROBE_DEFER) {
+                       clk_disable_unprepare(dev->clk);
                        return rc;
+               }
        }
 
        if (!of_property_read_u32(pdev->dev.of_node, "atmel,fifo-size",