diff mbox series

[3/3] watchdog: rti: Simplify with dev_err_probe()

Message ID 20200901153141.18960-3-krzk@kernel.org (mailing list archive)
State Accepted
Headers show
Series [1/3] watchdog: cadence: Simplify with dev_err_probe() | expand

Commit Message

Krzysztof Kozlowski Sept. 1, 2020, 3:31 p.m. UTC
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and the error value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

It is unusual to expect deferred probe from pm_runtime_get()...
---
 drivers/watchdog/rti_wdt.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Guenter Roeck Sept. 1, 2020, 8:19 p.m. UTC | #1
On Tue, Sep 01, 2020 at 05:31:41PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe().  Less code and the error value gets printed.
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

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

> 
> ---
> 
> It is unusual to expect deferred probe from pm_runtime_get()...
> ---
>  drivers/watchdog/rti_wdt.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
> index 705e8f7523e8..836319cbaca9 100644
> --- a/drivers/watchdog/rti_wdt.c
> +++ b/drivers/watchdog/rti_wdt.c
> @@ -205,11 +205,8 @@ static int rti_wdt_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	clk = clk_get(dev, NULL);
> -	if (IS_ERR(clk)) {
> -		if (PTR_ERR(clk) != -EPROBE_DEFER)
> -			dev_err(dev, "failed to get clock\n");
> -		return PTR_ERR(clk);
> -	}
> +	if (IS_ERR(clk))
> +		return dev_err_probe(dev, PTR_ERR(clk), "failed to get clock\n");
>  
>  	wdt->freq = clk_get_rate(clk);
>  
> @@ -230,11 +227,8 @@ static int rti_wdt_probe(struct platform_device *pdev)
>  
>  	pm_runtime_enable(dev);
>  	ret = pm_runtime_get_sync(dev);
> -	if (ret) {
> -		if (ret != -EPROBE_DEFER)
> -			dev_err(&pdev->dev, "runtime pm failed\n");
> -		return ret;
> -	}
> +	if (ret)
> +		return dev_err_probe(dev, ret, "runtime pm failed\n");
>  
>  	platform_set_drvdata(pdev, wdt);
>  
> -- 
> 2.17.1
>
diff mbox series

Patch

diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index 705e8f7523e8..836319cbaca9 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -205,11 +205,8 @@  static int rti_wdt_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	clk = clk_get(dev, NULL);
-	if (IS_ERR(clk)) {
-		if (PTR_ERR(clk) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get clock\n");
-		return PTR_ERR(clk);
-	}
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "failed to get clock\n");
 
 	wdt->freq = clk_get_rate(clk);
 
@@ -230,11 +227,8 @@  static int rti_wdt_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(dev);
 	ret = pm_runtime_get_sync(dev);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "runtime pm failed\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "runtime pm failed\n");
 
 	platform_set_drvdata(pdev, wdt);