diff mbox series

[8/9] watchdog: of_xilinx_wdt: Remove passing null pointer

Message ID 1615805214-24857-9-git-send-email-srinivas.neeli@xilinx.com (mailing list archive)
State Superseded
Headers show
Series watchdog: of_xilinx_wdt: Update on xilinx watchdog driver | expand

Commit Message

Srinivas Neeli March 15, 2021, 10:46 a.m. UTC
clk is an optional property, if clock not defined,
calling clk_prepare_enable() and devm_add_action_or_reset()
are not useful.
so calling these two apis only when clock is present.

Addresses-Coverity:"FORWARD_NULL"

Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
 drivers/watchdog/of_xilinx_wdt.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Comments

Guenter Roeck March 16, 2021, 2:33 a.m. UTC | #1
On 3/15/21 3:46 AM, Srinivas Neeli wrote:
> clk is an optional property, if clock not defined,
> calling clk_prepare_enable() and devm_add_action_or_reset()
> are not useful.
> so calling these two apis only when clock is present.
> 
> Addresses-Coverity:"FORWARD_NULL"
> 
> Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/of_xilinx_wdt.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c
> index 3656e716b4f7..ad35c93b7684 100644
> --- a/drivers/watchdog/of_xilinx_wdt.c
> +++ b/drivers/watchdog/of_xilinx_wdt.c
> @@ -520,6 +520,16 @@ static int xwdt_probe(struct platform_device *pdev)
>  				 "The watchdog clock freq cannot be obtained\n");
>  	} else {
>  		pfreq = clk_get_rate(xdev->clk);
> +		rc = clk_prepare_enable(xdev->clk);
> +
> +		if (rc) {
> +			dev_err(dev, "unable to enable clock\n");
> +			return rc;
> +		}
> +		rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare,
> +					      xdev->clk);
> +		if (rc)
> +			return rc;
>  	}
>  
>  	if (wdttype == XWDT_WDT) {
> @@ -554,16 +564,6 @@ static int xwdt_probe(struct platform_device *pdev)
>  	spin_lock_init(&xdev->spinlock);
>  	watchdog_set_drvdata(xilinx_wdt_wdd, xdev);
>  
> -	rc = clk_prepare_enable(xdev->clk);
> -	if (rc) {
> -		dev_err(dev, "unable to enable clock\n");
> -		return rc;
> -	}
> -	rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare,
> -				      xdev->clk);
> -	if (rc)
> -		return rc;
> -
>  	if (wdttype == XWDT_WDT) {
>  		rc = xwdt_selftest(xdev);
>  		if (rc == XWT_TIMER_FAILED) {
>
diff mbox series

Patch

diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c
index 3656e716b4f7..ad35c93b7684 100644
--- a/drivers/watchdog/of_xilinx_wdt.c
+++ b/drivers/watchdog/of_xilinx_wdt.c
@@ -520,6 +520,16 @@  static int xwdt_probe(struct platform_device *pdev)
 				 "The watchdog clock freq cannot be obtained\n");
 	} else {
 		pfreq = clk_get_rate(xdev->clk);
+		rc = clk_prepare_enable(xdev->clk);
+
+		if (rc) {
+			dev_err(dev, "unable to enable clock\n");
+			return rc;
+		}
+		rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare,
+					      xdev->clk);
+		if (rc)
+			return rc;
 	}
 
 	if (wdttype == XWDT_WDT) {
@@ -554,16 +564,6 @@  static int xwdt_probe(struct platform_device *pdev)
 	spin_lock_init(&xdev->spinlock);
 	watchdog_set_drvdata(xilinx_wdt_wdd, xdev);
 
-	rc = clk_prepare_enable(xdev->clk);
-	if (rc) {
-		dev_err(dev, "unable to enable clock\n");
-		return rc;
-	}
-	rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare,
-				      xdev->clk);
-	if (rc)
-		return rc;
-
 	if (wdttype == XWDT_WDT) {
 		rc = xwdt_selftest(xdev);
 		if (rc == XWT_TIMER_FAILED) {