[PATCH] crypto: amcc: trng: use devm_of_iomap()

Rosen Penev <[email protected]>
Newsgroups org.kernel.vger.linux-crypto,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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
Signed-off-by: Rosen Penev <[email protected]>
---
 drivers/crypto/amcc/crypto4xx_trng.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/amcc/crypto4xx_trng.c b/drivers/crypto/amcc/crypto4xx_trng.c
index cfd66b779ce1..4dd699c41c8a 100644
--- a/drivers/crypto/amcc/crypto4xx_trng.c
+++ b/drivers/crypto/amcc/crypto4xx_trng.c
@@ -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);
 	}
 }
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.