All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] crypto: amcc: Hold the reference returned by of_find_compatible_node
@ 2022-06-30  8:36 Liang He
  2022-06-30  8:36 ` [PATCH v2 2/2] crypto: nx: " Liang He
  2022-07-08  7:59 ` [PATCH v2 1/2] crypto: amcc: " Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Liang He @ 2022-06-30  8:36 UTC (permalink / raw)
  To: herbert, davem, mpe, benh, paulus, windhl, linux-crypto

In crypto4xx_probe(), we should hold the reference returned by
of_find_compatible_node() and use it to call of_node_put to keep
 refcount balance.

Signed-off-by: Liang He <windhl@126.com>
---
 changelog:
 
 v2: split v1 into two commits, use short coding format for 'np=xx;'
 v1: fix bugs in two directories (amcc,nx) of crypto

 v1-link: https://lore.kernel.org/all/20220621073742.4081013-1-windhl@126.com/

 drivers/crypto/amcc/crypto4xx_core.c | 40 +++++++++++++++++-----------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
index 8278d98074e9..280f4b0e7133 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -1378,6 +1378,7 @@ static int crypto4xx_probe(struct platform_device *ofdev)
 	struct resource res;
 	struct device *dev = &ofdev->dev;
 	struct crypto4xx_core_device *core_dev;
+	struct device_node *np;
 	u32 pvr;
 	bool is_revb = true;
 
@@ -1385,29 +1386,36 @@ static int crypto4xx_probe(struct platform_device *ofdev)
 	if (rc)
 		return -ENODEV;
 
-	if (of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-crypto")) {
+	np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-crypto");
+	if (np) {
 		mtdcri(SDR0, PPC460EX_SDR0_SRST,
 		       mfdcri(SDR0, PPC460EX_SDR0_SRST) | PPC460EX_CE_RESET);
 		mtdcri(SDR0, PPC460EX_SDR0_SRST,
 		       mfdcri(SDR0, PPC460EX_SDR0_SRST) & ~PPC460EX_CE_RESET);
-	} else if (of_find_compatible_node(NULL, NULL,
-			"amcc,ppc405ex-crypto")) {
-		mtdcri(SDR0, PPC405EX_SDR0_SRST,
-		       mfdcri(SDR0, PPC405EX_SDR0_SRST) | PPC405EX_CE_RESET);
-		mtdcri(SDR0, PPC405EX_SDR0_SRST,
-		       mfdcri(SDR0, PPC405EX_SDR0_SRST) & ~PPC405EX_CE_RESET);
-		is_revb = false;
-	} else if (of_find_compatible_node(NULL, NULL,
-			"amcc,ppc460sx-crypto")) {
-		mtdcri(SDR0, PPC460SX_SDR0_SRST,
-		       mfdcri(SDR0, PPC460SX_SDR0_SRST) | PPC460SX_CE_RESET);
-		mtdcri(SDR0, PPC460SX_SDR0_SRST,
-		       mfdcri(SDR0, PPC460SX_SDR0_SRST) & ~PPC460SX_CE_RESET);
 	} else {
-		printk(KERN_ERR "Crypto Function Not supported!\n");
-		return -EINVAL;
+		np = of_find_compatible_node(NULL, NULL, "amcc,ppc405ex-crypto");
+		if (np) {
+			mtdcri(SDR0, PPC405EX_SDR0_SRST,
+				   mfdcri(SDR0, PPC405EX_SDR0_SRST) | PPC405EX_CE_RESET);
+			mtdcri(SDR0, PPC405EX_SDR0_SRST,
+				   mfdcri(SDR0, PPC405EX_SDR0_SRST) & ~PPC405EX_CE_RESET);
+			is_revb = false;
+		} else {
+			np = of_find_compatible_node(NULL, NULL, "amcc,ppc460sx-crypto");
+			if (np) {
+				mtdcri(SDR0, PPC460SX_SDR0_SRST,
+					mfdcri(SDR0, PPC460SX_SDR0_SRST) | PPC460SX_CE_RESET);
+				mtdcri(SDR0, PPC460SX_SDR0_SRST,
+					mfdcri(SDR0, PPC460SX_SDR0_SRST) & ~PPC460SX_CE_RESET);
+			} else {
+				printk(KERN_ERR "Crypto Function Not supported!\n");
+				return -EINVAL;
+			}
+		}
 	}
 
+	of_node_put(np);
+
 	core_dev = kzalloc(sizeof(struct crypto4xx_core_device), GFP_KERNEL);
 	if (!core_dev)
 		return -ENOMEM;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] crypto: nx: Hold the reference returned by of_find_compatible_node
  2022-06-30  8:36 [PATCH v2 1/2] crypto: amcc: Hold the reference returned by of_find_compatible_node Liang He
@ 2022-06-30  8:36 ` Liang He
  2022-07-08  7:59 ` [PATCH v2 1/2] crypto: amcc: " Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Liang He @ 2022-06-30  8:36 UTC (permalink / raw)
  To: herbert, davem, mpe, benh, paulus, windhl, linux-crypto

In nx842_pseries_init(), we should hold the reference returned by
of_find_compatible_node() and use it to call of_node_put to keep
refcount balance.

Signed-off-by: Liang He <windhl@126.com>
---
 changelog:

 v2: split v1 into two commits
 v1: fix bugs in two directories (amcc,nx) of crypto

 v1-link: https://lore.kernel.org/all/20220621073742.4081013-1-windhl@126.com/


 drivers/crypto/nx/nx-common-pseries.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/nx/nx-common-pseries.c b/drivers/crypto/nx/nx-common-pseries.c
index 7584a34ba88c..3ea334b7f820 100644
--- a/drivers/crypto/nx/nx-common-pseries.c
+++ b/drivers/crypto/nx/nx-common-pseries.c
@@ -1208,10 +1208,13 @@ static struct vio_driver nx842_vio_driver = {
 static int __init nx842_pseries_init(void)
 {
 	struct nx842_devdata *new_devdata;
+	struct device_node *np;
 	int ret;
 
-	if (!of_find_compatible_node(NULL, NULL, "ibm,compression"))
+	np = of_find_compatible_node(NULL, NULL, "ibm,compression");
+	if (!np)
 		return -ENODEV;
+	of_node_put(np);
 
 	RCU_INIT_POINTER(devdata, NULL);
 	new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/2] crypto: amcc: Hold the reference returned by of_find_compatible_node
  2022-06-30  8:36 [PATCH v2 1/2] crypto: amcc: Hold the reference returned by of_find_compatible_node Liang He
  2022-06-30  8:36 ` [PATCH v2 2/2] crypto: nx: " Liang He
@ 2022-07-08  7:59 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2022-07-08  7:59 UTC (permalink / raw)
  To: Liang He; +Cc: davem, mpe, benh, paulus, linux-crypto

On Thu, Jun 30, 2022 at 04:36:56PM +0800, Liang He wrote:
> In crypto4xx_probe(), we should hold the reference returned by
> of_find_compatible_node() and use it to call of_node_put to keep
>  refcount balance.
> 
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  changelog:
>  
>  v2: split v1 into two commits, use short coding format for 'np=xx;'
>  v1: fix bugs in two directories (amcc,nx) of crypto
> 
>  v1-link: https://lore.kernel.org/all/20220621073742.4081013-1-windhl@126.com/
> 
>  drivers/crypto/amcc/crypto4xx_core.c | 40 +++++++++++++++++-----------
>  1 file changed, 24 insertions(+), 16 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-08  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30  8:36 [PATCH v2 1/2] crypto: amcc: Hold the reference returned by of_find_compatible_node Liang He
2022-06-30  8:36 ` [PATCH v2 2/2] crypto: nx: " Liang He
2022-07-08  7:59 ` [PATCH v2 1/2] crypto: amcc: " Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.