Skip to content

Commit

Permalink
hwrng: ingenic - use dev_err_probe in error paths
Browse files Browse the repository at this point in the history
Use dev_err_probe in error paths to make the code a bit shorter.

Signed-off-by: Martin Kaiser <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
martin-kaiser authored and herbertx committed Jul 22, 2023
1 parent e4ab6e7 commit 6257490
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions drivers/char/hw_random/ingenic-trng.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,23 @@ static int ingenic_trng_probe(struct platform_device *pdev)
return -ENOMEM;

trng->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(trng->base)) {
pr_err("%s: Failed to map DTRNG registers\n", __func__);
return PTR_ERR(trng->base);
}
if (IS_ERR(trng->base))
return dev_err_probe(&pdev->dev, PTR_ERR(trng->base),
"%s: Failed to map DTRNG registers\n", __func__);

clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(clk)) {
pr_crit("%s: Cannot get and enable DTRNG clock\n", __func__);
return PTR_ERR(clk);
}
if (IS_ERR(clk))
return dev_err_probe(&pdev->dev, PTR_ERR(clk),
"%s: Cannot get and enable DTRNG clock\n", __func__);

trng->rng.name = pdev->name;
trng->rng.init = ingenic_trng_init;
trng->rng.cleanup = ingenic_trng_cleanup;
trng->rng.read = ingenic_trng_read;

ret = hwrng_register(&trng->rng);
if (ret) {
dev_err(&pdev->dev, "Failed to register hwrng\n");
return ret;
}
if (ret)
return dev_err_probe(&pdev->dev, ret, "Failed to register hwrng\n");

platform_set_drvdata(pdev, trng);

Expand Down

0 comments on commit 6257490

Please sign in to comment.