diff mbox series

[1/3] hwrng: xgene - Simplify using dev_err_probe()

Message ID 20230214162829.113148-2-u.kleine-koenig@pengutronix.de
State Accepted
Commit 11f92a1308795294b0ad694f6a260c9b9c62fa51
Headers show
Series hwrng: xgene - Some improvements | expand

Commit Message

Uwe Kleine-König Feb. 14, 2023, 4:28 p.m. UTC
dev_err_probe simplifies the idiom:

	if (ret != -EPROBE_DEFER)
		dev_err(...)
	return ret;

, emits the error code in a human readable way and even yields a useful
entry in /sys/kernel/debug/devices_deferred in the EPROBE_DEFER case.

So simplify and at the same time improve the driver by using
dev_err_probe().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/char/hw_random/xgene-rng.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/drivers/char/hw_random/xgene-rng.c b/drivers/char/hw_random/xgene-rng.c
index 008e6db9ce01..a6a30686a58b 100644
--- a/drivers/char/hw_random/xgene-rng.c
+++ b/drivers/char/hw_random/xgene-rng.c
@@ -337,10 +337,8 @@  static int xgene_rng_probe(struct platform_device *pdev)
 
 	rc = devm_request_irq(&pdev->dev, ctx->irq, xgene_rng_irq_handler, 0,
 				dev_name(&pdev->dev), ctx);
-	if (rc) {
-		dev_err(&pdev->dev, "Could not request RNG alarm IRQ\n");
-		return rc;
-	}
+	if (rc)
+		return dev_err_probe(&pdev->dev, rc, "Could not request RNG alarm IRQ\n");
 
 	/* Enable IP clock */
 	ctx->clk = devm_clk_get(&pdev->dev, NULL);
@@ -348,30 +346,25 @@  static int xgene_rng_probe(struct platform_device *pdev)
 		dev_warn(&pdev->dev, "Couldn't get the clock for RNG\n");
 	} else {
 		rc = clk_prepare_enable(ctx->clk);
-		if (rc) {
-			dev_warn(&pdev->dev,
-				 "clock prepare enable failed for RNG");
-			return rc;
-		}
+		if (rc)
+			return dev_err_probe(&pdev->dev, rc,
+					     "clock prepare enable failed for RNG");
 	}
 
 	xgene_rng_func.priv = (unsigned long) ctx;
 
 	rc = devm_hwrng_register(&pdev->dev, &xgene_rng_func);
 	if (rc) {
-		dev_err(&pdev->dev, "RNG registering failed error %d\n", rc);
 		if (!IS_ERR(ctx->clk))
 			clk_disable_unprepare(ctx->clk);
-		return rc;
+		return dev_err_probe(&pdev->dev, rc, "RNG registering failed\n");
 	}
 
 	rc = device_init_wakeup(&pdev->dev, 1);
 	if (rc) {
-		dev_err(&pdev->dev, "RNG device_init_wakeup failed error %d\n",
-			rc);
 		if (!IS_ERR(ctx->clk))
 			clk_disable_unprepare(ctx->clk);
-		return rc;
+		return dev_err_probe(&pdev->dev, rc, "RNG device_init_wakeup failed\n");
 	}
 
 	return 0;