crypto: crypto4xx - use int for ppc4xx_trng_probe()

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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Rosen Penev 2026-09-04 16:01:44 -07:00 committed by Herbert Xu
parent 13b481b15e
commit f033e862a3
3 changed files with 18 additions and 9 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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