blob: d85280ceb06b7b7e79040f9bb50987cbb6bb6d42 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 76087c548649ea0fae04a0538f9de12546c5c680 Mon Sep 17 00:00:00 2001
2From: Andrey Smirnov <andrew.smirnov@gmail.com>
3Date: Tue, 22 Oct 2019 08:30:08 -0700
4Subject: [PATCH] crypto: caam - use devres to unmap memory
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Use devres to unmap memory and drop corresponding iounmap() call.
10
11Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
12Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
13Cc: Chris Healy <cphealy@gmail.com>
14Cc: Lucas Stach <l.stach@pengutronix.de>
15Cc: Horia Geantă <horia.geanta@nxp.com>
16Cc: Herbert Xu <herbert@gondor.apana.org.au>
17Cc: Iuliana Prodan <iuliana.prodan@nxp.com>
18Cc: linux-crypto@vger.kernel.org
19Cc: linux-kernel@vger.kernel.org
20Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
21(cherry picked from commit 66e93b28075d3cae568ed97ef78789afa5a6eb36)
22---
23 drivers/crypto/caam/ctrl.c | 28 +++++++++-------------------
24 1 file changed, 9 insertions(+), 19 deletions(-)
25
26--- a/drivers/crypto/caam/ctrl.c
27+++ b/drivers/crypto/caam/ctrl.c
28@@ -308,11 +308,9 @@ static int caam_remove(struct platform_d
29 {
30 struct device *ctrldev;
31 struct caam_drv_private *ctrlpriv;
32- struct caam_ctrl __iomem *ctrl;
33
34 ctrldev = &pdev->dev;
35 ctrlpriv = dev_get_drvdata(ctrldev);
36- ctrl = (struct caam_ctrl __iomem *)ctrlpriv->ctrl;
37
38 /* Remove platform devices under the crypto node */
39 of_platform_depopulate(ctrldev);
40@@ -334,9 +332,6 @@ static int caam_remove(struct platform_d
41 debugfs_remove_recursive(ctrlpriv->dfs_root);
42 #endif
43
44- /* Unmap controller region */
45- iounmap(ctrl);
46-
47 return 0;
48 }
49
50@@ -611,10 +606,11 @@ static int caam_probe(struct platform_de
51
52 /* Get configuration properties from device tree */
53 /* First, get register page */
54- ctrl = of_iomap(nprop, 0);
55- if (!ctrl) {
56+ ctrl = devm_of_iomap(dev, nprop, 0, NULL);
57+ ret = PTR_ERR_OR_ZERO(ctrl);
58+ if (ret) {
59 dev_err(dev, "caam: of_iomap() failed\n");
60- return -ENOMEM;
61+ return ret;
62 }
63
64 caam_little_end = !(bool)(rd_reg32(&ctrl->perfmon.status) &
65@@ -632,22 +628,18 @@ static int caam_probe(struct platform_de
66 if (ctrlpriv->qi_present && !caam_dpaa2) {
67 ret = qman_is_probed();
68 if (!ret) {
69- ret = -EPROBE_DEFER;
70- goto iounmap_ctrl;
71+ return -EPROBE_DEFER;
72 } else if (ret < 0) {
73 dev_err(dev, "failing probe due to qman probe error\n");
74- ret = -ENODEV;
75- goto iounmap_ctrl;
76+ return -ENODEV;
77 }
78
79 ret = qman_portals_probed();
80 if (!ret) {
81- ret = -EPROBE_DEFER;
82- goto iounmap_ctrl;
83+ return -EPROBE_DEFER;
84 } else if (ret < 0) {
85 dev_err(dev, "failing probe due to qman portals probe error\n");
86- ret = -ENODEV;
87- goto iounmap_ctrl;
88+ return -ENODEV;
89 }
90 }
91 #endif
92@@ -720,7 +712,7 @@ static int caam_probe(struct platform_de
93 ret = dma_set_mask_and_coherent(dev, caam_get_dma_mask(dev));
94 if (ret) {
95 dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
96- goto iounmap_ctrl;
97+ return ret;
98 }
99
100 ctrlpriv->era = caam_get_era(ctrl);
101@@ -925,8 +917,6 @@ shutdown_qi:
102 if (ctrlpriv->qi_init)
103 caam_qi_shutdown(dev);
104 #endif
105-iounmap_ctrl:
106- iounmap(ctrl);
107 return ret;
108 }
109