Re: [PATCH] hwrng: bcm2835 - remove redundant null check

2021-02-09 Thread Florian Fainelli
On 2/8/21 10:25 PM, Tian Tao wrote:
> 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 

I don't believe this is going to work unless you also change
devm_clk_get() to devm_clk_get_optional() which will deal with -ENOENT
and return NULL in that case, once you do that we can remove the NULL
pointer checks.
-- 
Florian


[PATCH] hwrng: bcm2835 - remove redundant null check

2021-02-08 Thread Tian Tao
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 
---
 drivers/char/hw_random/bcm2835-rng.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/char/hw_random/bcm2835-rng.c 
b/drivers/char/hw_random/bcm2835-rng.c
index 1a7c43b..ed0aa51 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -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 {
-- 
2.7.4