OSDN Git Service

hwrng: bcm2835 - remove redundant null check
authorTian Tao <tiantao6@hisilicon.com>
Wed, 10 Feb 2021 01:14:58 +0000 (09:14 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 7 Mar 2021 04:13:14 +0000 (15:13 +1100)
clk_prepare_enable() and clk_disable_unprepare() will check
NULL clock parameter, so It is not necessary to add additional checks.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/char/hw_random/bcm2835-rng.c

index 1a7c43b..be5be39 100644 (file)
@@ -88,11 +88,9 @@ static int bcm2835_rng_init(struct hwrng *rng)
        int ret = 0;
        u32 val;
 
-       if (!IS_ERR(priv->clk)) {
-               ret = clk_prepare_enable(priv->clk);
-               if (ret)
-                       return ret;
-       }
+       ret = clk_prepare_enable(priv->clk);
+       if (ret)
+               return ret;
 
        if (priv->mask_interrupts) {
                /* mask the interrupt */
@@ -115,8 +113,7 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)
        /* disable rng hardware */
        rng_writel(priv, 0, RNG_CTRL);
 
-       if (!IS_ERR(priv->clk))
-               clk_disable_unprepare(priv->clk);
+       clk_disable_unprepare(priv->clk);
 }
 
 struct bcm2835_rng_of_data {
@@ -155,9 +152,9 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
                return PTR_ERR(priv->base);
 
        /* Clock is optional on most platforms */
-       priv->clk = devm_clk_get(dev, NULL);
-       if (PTR_ERR(priv->clk) == -EPROBE_DEFER)
-               return -EPROBE_DEFER;
+       priv->clk = devm_clk_get_optional(dev, NULL);
+       if (IS_ERR(priv->clk))
+               return PTR_ERR(priv->clk);
 
        priv->rng.name = pdev->name;
        priv->rng.init = bcm2835_rng_init;