Skip to contentSkip to conversation

hwrng: cctrn - Simplify with dev_err_probe()

PATCH In review Krzysztof Kozlowski 3 participants 3 messages Aug 26, 2020 – Sep 4, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwrng: cctrn - Simplify with dev_err_probe()

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

---
 drivers/char/hw_random/cctrng.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/char/hw_random/cctrng.c +4 -5
index 619148fb2dc9..7a293f2147a0 100644
@@ -463,11 +463,10 @@ static int cc_trng_clk_init(struct cctrng_drvdata *drvdata)
 	int rc = 0;
 
 	clk = devm_clk_get_optional(dev, NULL);
-	if (IS_ERR(clk)) {
-		if (PTR_ERR(clk) != -EPROBE_DEFER)
-			dev_err(dev, "Error getting clock: %pe\n", clk);
-		return PTR_ERR(clk);
-	}
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk),
+				     "Error getting clock\n");
+
 	drvdata->clk = clk;
 
 	rc = clk_prepare_enable(drvdata->clk);
Signature · 1 line
2.17.1
maintainer Acked-by on v1 1/1
#1 lore raw

Hi Krzysztof,

Quoted 29 lines

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

---
 drivers/char/hw_random/cctrng.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/char/hw_random/cctrng.c index 619148fb2dc9..7a293f2147a0 100644

drivers/char/hw_random/cctrng.c +4 -5
@@ -463,11 +463,10 @@ static int cc_trng_clk_init(struct cctrng_drvdata
 *drvdata)
 	int rc = 0;
 
 	clk = devm_clk_get_optional(dev, NULL);
-	if (IS_ERR(clk)) {
-		if (PTR_ERR(clk) != -EPROBE_DEFER)
-			dev_err(dev, "Error getting clock: %pe\n", clk);
-		return PTR_ERR(clk);
-	}
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk),
+				     "Error getting clock\n");
+
 	drvdata->clk = clk;
 
Quoted 3 lines

rc = clk_prepare_enable(drvdata->clk);
--
2.17.1

Thanks for this code simplification. :-)

Hadar

maintainer
#2 lore raw
In reply to Krzysztof Kozlowski
Quoted 7 lines · Krzysztof Kozlowski

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

---
 drivers/char/hw_random/cctrng.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt