i2c: uniphier_f: error out if clock rate is zero
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 30 Nov 2015 09:53:35 +0000 (18:53 +0900)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 14 Dec 2015 09:59:26 +0000 (10:59 +0100)
This input clock is used to generate the sampling clock for I2C bus.
If the clock rate is zero, there is something wrong with the clock
driver.  Bail out with the appropriate error message in such a case.
It would make it easier to find the root cause of failure.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-uniphier-f.c

index e8d03bcfe3e0a408491d771ff6cdbf33ff2f52d1..67109e1d66c32ac57eccb6c4e50c260018c06879 100644 (file)
@@ -481,6 +481,10 @@ static int uniphier_fi2c_clk_init(struct device *dev,
                return ret;
 
        clk_rate = clk_get_rate(priv->clk);
+       if (!clk_rate) {
+               dev_err(dev, "input clock rate should not be zero\n");
+               return -EINVAL;
+       }
 
        uniphier_fi2c_reset(priv);
 
@@ -531,7 +535,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
 
        ret = uniphier_fi2c_clk_init(dev, priv);
        if (ret)
-               return ret;
+               goto err;
 
        ret = devm_request_irq(dev, irq, uniphier_fi2c_interrupt, 0,
                               pdev->name, priv);