Skip to contentSkip to conversation

watchdog: cadence: Simplify with dev_err_probe()

PATCH In review Krzysztof Kozlowski 2 participants 11 messages Sep 1, 2020 – Oct 2, 2020 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 watchdog: cadence: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

---
 drivers/watchdog/cadence_wdt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/watchdog/cadence_wdt.c +3 -6
index 672b184da875..bc99e9164930 100644
@@ -334,12 +334,9 @@ static int cdns_wdt_probe(struct platform_device *pdev)
 	watchdog_set_drvdata(cdns_wdt_device, wdt);
 
 	wdt->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(wdt->clk)) {
-		ret = PTR_ERR(wdt->clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "input clock not found\n");
-		return ret;
-	}
+	if (IS_ERR(wdt->clk))
+		return dev_err_probe(dev, PTR_ERR(wdt->clk),
+				     "input clock not found\n");
 
 	ret = clk_prepare_enable(wdt->clk);
 	if (ret) {
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 watchdog: davinci: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

---
 drivers/watchdog/davinci_wdt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/watchdog/davinci_wdt.c +3 -6
index 2b3f3cd382ef..e6eaba6bae5b 100644
@@ -206,12 +206,9 @@ static int davinci_wdt_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	davinci_wdt->clk = devm_clk_get(dev, NULL);
-
-	if (IS_ERR(davinci_wdt->clk)) {
-		if (PTR_ERR(davinci_wdt->clk) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get clock node\n");
-		return PTR_ERR(davinci_wdt->clk);
-	}
+	if (IS_ERR(davinci_wdt->clk))
+		return dev_err_probe(dev, PTR_ERR(davinci_wdt->clk),
+				     "failed to get clock node\n");
 
 	ret = clk_prepare_enable(davinci_wdt->clk);
 	if (ret) {
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] watchdog: davinci: Simplify with dev_err_probe()

Quoted 4 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

Quoted 27 lines
---
 drivers/watchdog/davinci_wdt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/watchdog/davinci_wdt.c +3 -6
index 2b3f3cd382ef..e6eaba6bae5b 100644
@@ -206,12 +206,9 @@ static int davinci_wdt_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	davinci_wdt->clk = devm_clk_get(dev, NULL);
-
-	if (IS_ERR(davinci_wdt->clk)) {
-		if (PTR_ERR(davinci_wdt->clk) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get clock node\n");
-		return PTR_ERR(davinci_wdt->clk);
-	}
+	if (IS_ERR(davinci_wdt->clk))
+		return dev_err_probe(dev, PTR_ERR(davinci_wdt->clk),
+				     "failed to get clock node\n");
 
 	ret = clk_prepare_enable(davinci_wdt->clk);
 	if (ret) {
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 2/3
#3 lore raw

Re: [PATCH 2/3] watchdog: davinci: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski
Quoted 4 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

Quoted 27 lines
---
 drivers/watchdog/davinci_wdt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/watchdog/davinci_wdt.c +3 -6
index 2b3f3cd382ef..e6eaba6bae5b 100644
@@ -206,12 +206,9 @@ static int davinci_wdt_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	davinci_wdt->clk = devm_clk_get(dev, NULL);
-
-	if (IS_ERR(davinci_wdt->clk)) {
-		if (PTR_ERR(davinci_wdt->clk) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get clock node\n");
-		return PTR_ERR(davinci_wdt->clk);
-	}
+	if (IS_ERR(davinci_wdt->clk))
+		return dev_err_probe(dev, PTR_ERR(davinci_wdt->clk),
+				     "failed to get clock node\n");
 
 	ret = clk_prepare_enable(davinci_wdt->clk);
 	if (ret) {
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/3 watchdog: rti: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

---

It is unusual to expect deferred probe from pm_runtime_get()...

---
 drivers/watchdog/rti_wdt.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/watchdog/rti_wdt.c +4 -10
index 705e8f7523e8..836319cbaca9 100644
@@ -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);
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 3/3
#5 lore raw

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

Quoted 4 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

Quoted 43 lines

---

It is unusual to expect deferred probe from pm_runtime_get()...

---
 drivers/watchdog/rti_wdt.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/watchdog/rti_wdt.c +4 -10
index 705e8f7523e8..836319cbaca9 100644
@@ -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);
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 3/3
#6 lore raw

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

In reply to Krzysztof Kozlowski
Quoted 4 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

Quoted 43 lines

---

It is unusual to expect deferred probe from pm_runtime_get()...

---
 drivers/watchdog/rti_wdt.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/watchdog/rti_wdt.c +4 -10
index 705e8f7523e8..836319cbaca9 100644
@@ -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);
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/3
#7 lore raw
In reply to Krzysztof Kozlowski
Quoted 4 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

Quoted 27 lines
---
 drivers/watchdog/cadence_wdt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/watchdog/cadence_wdt.c +3 -6
index 672b184da875..bc99e9164930 100644
@@ -334,12 +334,9 @@ static int cdns_wdt_probe(struct platform_device *pdev)
 	watchdog_set_drvdata(cdns_wdt_device, wdt);
 
 	wdt->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(wdt->clk)) {
-		ret = PTR_ERR(wdt->clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "input clock not found\n");
-		return ret;
-	}
+	if (IS_ERR(wdt->clk))
+		return dev_err_probe(dev, PTR_ERR(wdt->clk),
+				     "input clock not found\n");
 
 	ret = clk_prepare_enable(wdt->clk);
 	if (ret) {
Signature · 1 line
2.17.1
maintainer
#9 lore raw
Quoted 11 lines · Krzysztof Kozlowski
Quoted 7 lines · Guenter Roeck
Quoted 4 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

Thanks for the review. Who could pick up these patches?

They are queued up in my watchdog-next branch, and Wim usually picks up patches from there.

Guenter

maintainer Reviewed-by on v1 1/3
#10 lore raw
In reply to Krzysztof Kozlowski
Quoted 4 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed.

Hmm, I had replied to this but I don't see it on patchwork. Trying again.

Guenter

Quoted 27 lines
---
 drivers/watchdog/cadence_wdt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/watchdog/cadence_wdt.c +3 -6
index 672b184da875..bc99e9164930 100644
@@ -334,12 +334,9 @@ static int cdns_wdt_probe(struct platform_device *pdev)
 	watchdog_set_drvdata(cdns_wdt_device, wdt);
 
 	wdt->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(wdt->clk)) {
-		ret = PTR_ERR(wdt->clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "input clock not found\n");
-		return ret;
-	}
+	if (IS_ERR(wdt->clk))
+		return dev_err_probe(dev, PTR_ERR(wdt->clk),
+				     "input clock not found\n");
 
 	ret = clk_prepare_enable(wdt->clk);
 	if (ret) {
Signature · 1 line
2.17.1