crypto: amcc: trng: use int for ppc4xx_trng_probe()
PATCH 1/1 crypto: amcc: trng: 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 <[email protected]>
--- 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(-)
drivers/crypto/amcc/crypto4xx_core.c +5 -1
@@ -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:
drivers/crypto/amcc/crypto4xx_trng.c +10 -5
@@ -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)
drivers/crypto/amcc/crypto4xx_trng.h +3 -3
@@ -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
Signature · 1 line
2.55.0