All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <blum@kernel.org>
To: Olivia Mackall <olivia@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Thorsten Blum <blum@kernel.org>, Kees Cook <kees@kernel.org>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] hwrng: intel - simplify intel_rng_mod_init()
Date: Tue,  6 Oct 2026 19:26:27 +0200	[thread overview]
Message-ID: <20261006172628.103594-2-blum@kernel.org> (raw)

Return errors directly to simplify intel_rng_mod_init().

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 drivers/char/hw_random/intel-rng.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
index bc4aa9ea1195..b6a50e3e7a6a 100644
--- a/drivers/char/hw_random/intel-rng.c
+++ b/drivers/char/hw_random/intel-rng.c
@@ -327,7 +327,7 @@ static int __init intel_init_hw_struct(struct intel_rng_hw *intel_rng_hw,
 
 static int __init intel_rng_mod_init(void)
 {
-	int err = -ENODEV;
+	int err;
 	int i;
 	struct pci_dev *dev = NULL;
 	void __iomem *mem;
@@ -339,7 +339,7 @@ static int __init intel_rng_mod_init(void)
 				     NULL);
 
 	if (!dev)
-		goto out; /* Device not found. */
+		return -ENODEV;
 
 	if (no_fwh_detect < 0) {
 		pci_dev_put(dev);
@@ -349,8 +349,7 @@ static int __init intel_rng_mod_init(void)
 	intel_rng_hw = kmalloc_obj(*intel_rng_hw);
 	if (!intel_rng_hw) {
 		pci_dev_put(dev);
-		err = -ENOMEM;
-		goto out;
+		return -ENOMEM;
 	}
 
 	err = intel_init_hw_struct(intel_rng_hw, dev);
@@ -359,7 +358,7 @@ static int __init intel_rng_mod_init(void)
 		kfree(intel_rng_hw);
 		if (err == -ENODEV)
 			goto fwh_done;
-		goto out;
+		return err;
 	}
 
 	/*
@@ -375,21 +374,19 @@ static int __init intel_rng_mod_init(void)
 	iounmap(intel_rng_hw->mem);
 	kfree(intel_rng_hw);
 	if (err)
-		goto out;
+		return err;
 
 fwh_done:
-	err = -ENOMEM;
 	mem = ioremap(INTEL_RNG_ADDR, INTEL_RNG_ADDR_LEN);
 	if (!mem)
-		goto out;
+		return -ENOMEM;
 	intel_rng.priv = (unsigned long)mem;
 
 	/* Check for Random Number Generator */
-	err = -ENODEV;
 	hw_status = hwstatus_get(mem);
 	if ((hw_status & INTEL_RNG_PRESENT) == 0) {
 		iounmap(mem);
-		goto out;
+		return -ENODEV;
 	}
 
 	pr_info("Intel 82802 RNG detected\n");
@@ -398,10 +395,10 @@ static int __init intel_rng_mod_init(void)
 		pr_err(PFX "RNG registering failed (%d)\n",
 		       err);
 		iounmap(mem);
+		return err;
 	}
-out:
-	return err;
 
+	return 0;
 }
 
 static void __exit intel_rng_mod_exit(void)

base-commit: 4c3ca7c8c152278332590bfd3df1b0f086364759

                 reply	other threads:[~2026-10-06 17:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261006172628.103594-2-blum@kernel.org \
    --to=blum@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=kees@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olivia@selenic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.