From: Rosen Penev <rosenp@gmail.com>
To: linux-crypto@vger.kernel.org
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] crypto: amcc: trng: use int for ppc4xx_trng_probe()
Date: Fri, 4 Sep 2026 16:01:44 -0700 [thread overview]
Message-ID: <20260904230144.127071-1-rosenp@gmail.com> (raw)
Pass an error message to crypto4xx_probe() , which will allow handling
failure. The inline function returns 0 as trng is optional
functionality. Same with the of_node.
Add an extra goto in crypto4xx_probe() to unregister algs as registering
them happens before trng.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/amcc/crypto4xx_core.c | 6 +++++-
drivers/crypto/amcc/crypto4xx_trng.c | 15 ++++++++++-----
drivers/crypto/amcc/crypto4xx_trng.h | 6 +++---
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
index a044dce65cf4..acf18b71e54d 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -1315,9 +1315,13 @@ static int crypto4xx_probe(struct platform_device *ofdev)
if (rc)
goto err_irq;
- ppc4xx_trng_probe(core_dev);
+ rc = ppc4xx_trng_probe(core_dev);
+ if (rc)
+ goto err_crypto;
return 0;
+err_crypto:
+ crypto4xx_unregister_alg(core_dev->dev);
err_irq:
free_irq(core_dev->irq, core_dev);
err_tasklet:
diff --git a/drivers/crypto/amcc/crypto4xx_trng.c b/drivers/crypto/amcc/crypto4xx_trng.c
index cfd66b779ce1..83e9353529fc 100644
--- a/drivers/crypto/amcc/crypto4xx_trng.c
+++ b/drivers/crypto/amcc/crypto4xx_trng.c
@@ -68,7 +68,7 @@ static const struct of_device_id ppc4xx_trng_match[] = {
{},
};
-void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
+int ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
{
struct crypto4xx_device *dev = core_dev->dev;
struct device_node *trng = NULL;
@@ -79,17 +79,21 @@ void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
trng = of_find_matching_node(NULL, ppc4xx_trng_match);
if (!trng || !of_device_is_available(trng)) {
of_node_put(trng);
- return;
+ return 0;
}
dev->trng_base = of_iomap(trng, 0);
of_node_put(trng);
- if (!dev->trng_base)
+ if (!dev->trng_base) {
+ err = -EINVAL;
goto err_out;
+ }
rng = kzalloc_obj(*rng);
- if (!rng)
+ if (!rng) {
+ err = -ENOMEM;
goto err_out;
+ }
rng->name = KBUILD_MODNAME;
rng->data_present = ppc4xx_trng_data_present;
@@ -105,13 +109,14 @@ void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
err);
goto err_out;
}
- return;
+ return 0;
err_out:
iounmap(dev->trng_base);
kfree(rng);
dev->trng_base = NULL;
core_dev->trng = NULL;
+ return err;
}
void ppc4xx_trng_remove(struct crypto4xx_core_device *core_dev)
diff --git a/drivers/crypto/amcc/crypto4xx_trng.h b/drivers/crypto/amcc/crypto4xx_trng.h
index 7356716274cb..1030c3cfafd0 100644
--- a/drivers/crypto/amcc/crypto4xx_trng.h
+++ b/drivers/crypto/amcc/crypto4xx_trng.h
@@ -13,11 +13,11 @@
#define __CRYPTO4XX_TRNG_H__
#ifdef CONFIG_HW_RANDOM_PPC4XX
-void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev);
+int ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev);
void ppc4xx_trng_remove(struct crypto4xx_core_device *core_dev);
#else
-static inline void ppc4xx_trng_probe(
- struct crypto4xx_core_device *dev __maybe_unused) { }
+static inline int ppc4xx_trng_probe(
+ struct crypto4xx_core_device *dev __maybe_unused) { return 0; }
static inline void ppc4xx_trng_remove(
struct crypto4xx_core_device *dev __maybe_unused) { }
#endif
--
2.55.0
reply other threads:[~2026-09-04 23:01 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=20260904230144.127071-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®