Skip to contentSkip to conversation

crypto: amcc: trng: use devm_of_iomap()

PATCH In review Rosen Penev 2 participants 3 messages Aug 12 – Sep 4 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: amcc: trng: use devm_of_iomap()

Convert of_iomap() to devm_of_iomap() so that the TRNG register mapping is automatically unmapped on driver detach, eliminating the need for manual iounmap() calls in the error and remove paths.

Assisted-by opencode:big-pickle
---
 drivers/crypto/amcc/crypto4xx_trng.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/amcc/crypto4xx_trng.c +2 -5
index cfd66b779ce1..4dd699c41c8a 100644
@@ -82,9 +82,9 @@ void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
 		return;
 	}
 
-	dev->trng_base = of_iomap(trng, 0);
+	dev->trng_base = devm_of_iomap(core_dev->device, trng, 0, NULL);
 	of_node_put(trng);
-	if (!dev->trng_base)
+	if (IS_ERR(dev->trng_base))
 		goto err_out;
 
 	rng = kzalloc_obj(*rng);
@@ -108,9 +108,7 @@ void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev)
 	return;
 
 err_out:
-	iounmap(dev->trng_base);
 	kfree(rng);
-	dev->trng_base = NULL;
 	core_dev->trng = NULL;
 }
 
@@ -121,7 +119,6 @@ void ppc4xx_trng_remove(struct crypto4xx_core_device *core_dev)
 
 		devm_hwrng_unregister(core_dev->device, core_dev->trng);
 		ppc4xx_trng_enable(dev, false);
-		iounmap(dev->trng_base);
 		kfree(core_dev->trng);
 	}
 }
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 9 lines · Rosen Penev

Convert of_iomap() to devm_of_iomap() so that the TRNG register mapping is automatically unmapped on driver detach, eliminating the need for manual iounmap() calls in the error and remove paths.

Assisted-by opencode:big-pickle
---
 drivers/crypto/amcc/crypto4xx_trng.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Please check Sashiko:

https://sashiko.dev/#/patchset/20260812185747.79173-1-rosenp%40gmail.com

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
Quoted 12 lines · Herbert Xu
Quoted 9 lines · Rosen Penev

Convert of_iomap() to devm_of_iomap() so that the TRNG register mapping is automatically unmapped on driver detach, eliminating the need for manual iounmap() calls in the error and remove paths.

Assisted-by opencode:big-pickle
---
 drivers/crypto/amcc/crypto4xx_trng.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
Quoted 5 lines

Please check Sashiko:

https://sashiko.dev/#/patchset/20260812185747.79173-1-rosenp%40gmail.com

Thanks,

So I guess conversion from void to int is needed beforehand.

Quoted 4 lines

--
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt