From 11f92a1308795294b0ad694f6a260c9b9c62fa51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 14 Feb 2023 17:28:27 +0100 Subject: [PATCH] hwrng: xgene - Simplify using dev_err_probe() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Herbert Xu --- drivers/char/hw_random/xgene-rng.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/char/hw_random/xgene-rng.c b/drivers/char/hw_random/xgene-rng.c index 008e6db..a6a3068 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; -- 2.7.4