diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2023-02-14 17:28:27 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2023-03-10 19:10:09 +0800 |
commit | 11f92a1308795294b0ad694f6a260c9b9c62fa51 (patch) | |
tree | 1ce3bf0d11e1e4e54afc87fb7a7a239d307bf0a9 | |
parent | 4c9edf17c0b44655c565b59a956161a2ee125cca (diff) | |
download | linux-stable-11f92a1308795294b0ad694f6a260c9b9c62fa51.tar.gz linux-stable-11f92a1308795294b0ad694f6a260c9b9c62fa51.tar.bz2 linux-stable-11f92a1308795294b0ad694f6a260c9b9c62fa51.zip |
hwrng: xgene - Simplify using dev_err_probe()
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/char/hw_random/xgene-rng.c | 21 |
1 files changed, 7 insertions, 14 deletions
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; |