linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remoteproc: Use of_property_present()
@ 2024-07-31 19:12 Rob Herring (Arm)
  2024-08-01  1:51 ` Peng Fan
  2024-08-13 15:24 ` Mathieu Poirier
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring (Arm) @ 2024-07-31 19:12 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel

Use of_property_present() to test for property presence rather than
of_(find|get)_property(). This is part of a larger effort to remove
callers of of_find_property() and similar functions. of_find_property()
leaks the DT struct property and data pointers which is a problem for
dynamically allocated nodes which may be freed.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 drivers/remoteproc/imx_dsp_rproc.c      | 2 +-
 drivers/remoteproc/imx_rproc.c          | 2 +-
 drivers/remoteproc/xlnx_r5_remoteproc.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 087506e21508..376187ad5754 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -509,7 +509,7 @@ static int imx_dsp_rproc_mbox_alloc(struct imx_dsp_rproc *priv)
 	struct mbox_client *cl;
 	int ret;
 
-	if (!of_get_property(dev->of_node, "mbox-names", NULL))
+	if (!of_property_present(dev->of_node, "mbox-names"))
 		return 0;
 
 	cl = &priv->cl;
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 144c8e9a642e..8d7ecc809c67 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -807,7 +807,7 @@ static int imx_rproc_xtr_mbox_init(struct rproc *rproc)
 	if (priv->tx_ch && priv->rx_ch)
 		return 0;
 
-	if (!of_get_property(dev->of_node, "mbox-names", NULL))
+	if (!of_property_present(dev->of_node, "mbox-names"))
 		return 0;
 
 	cl = &priv->cl;
diff --git a/drivers/remoteproc/xlnx_r5_remoteproc.c b/drivers/remoteproc/xlnx_r5_remoteproc.c
index 596f3ffb8935..2cea97c746fd 100644
--- a/drivers/remoteproc/xlnx_r5_remoteproc.c
+++ b/drivers/remoteproc/xlnx_r5_remoteproc.c
@@ -1059,7 +1059,7 @@ static int zynqmp_r5_core_init(struct zynqmp_r5_cluster *cluster,
 	r5_core = cluster->r5_cores[0];
 
 	/* Maintain backward compatibility for zynqmp by using hardcode TCM address. */
-	if (of_find_property(r5_core->np, "reg", NULL))
+	if (of_property_present(r5_core->np, "reg"))
 		ret = zynqmp_r5_get_tcm_node_from_dt(cluster);
 	else if (device_is_compatible(dev, "xlnx,zynqmp-r5fss"))
 		ret = zynqmp_r5_get_tcm_node(cluster);
@@ -1086,7 +1086,7 @@ static int zynqmp_r5_core_init(struct zynqmp_r5_cluster *cluster,
 			return ret;
 		}
 
-		if (of_find_property(dev_of_node(dev), "xlnx,tcm-mode", NULL) ||
+		if (of_property_present(dev_of_node(dev), "xlnx,tcm-mode") ||
 		    device_is_compatible(dev, "xlnx,zynqmp-r5fss")) {
 			ret = zynqmp_pm_set_tcm_config(r5_core->pm_domain_id,
 						       tcm_mode);
@@ -1147,7 +1147,7 @@ static int zynqmp_r5_cluster_init(struct zynqmp_r5_cluster *cluster)
 		return -EINVAL;
 	}
 
-	if (of_find_property(dev_node, "xlnx,tcm-mode", NULL)) {
+	if (of_property_present(dev_node, "xlnx,tcm-mode")) {
 		ret = of_property_read_u32(dev_node, "xlnx,tcm-mode", (u32 *)&tcm_mode);
 		if (ret)
 			return ret;
-- 
2.43.0



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

* RE: [PATCH] remoteproc: Use of_property_present()
  2024-07-31 19:12 [PATCH] remoteproc: Use of_property_present() Rob Herring (Arm)
@ 2024-08-01  1:51 ` Peng Fan
  2024-08-13 15:24 ` Mathieu Poirier
  1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2024-08-01  1:51 UTC (permalink / raw)
  To: Rob Herring (Arm), Bjorn Andersson, Mathieu Poirier, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org

> Subject: [PATCH] remoteproc: Use of_property_present()
> 
> Use of_property_present() to test for property presence rather than
> of_(find|get)_property(). This is part of a larger effort to remove callers
> of of_find_property() and similar functions. of_find_property() leaks the
> DT struct property and data pointers which is a problem for
> dynamically allocated nodes which may be freed.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>  drivers/remoteproc/imx_dsp_rproc.c      | 2 +-
>  drivers/remoteproc/imx_rproc.c          | 2 +-
>  drivers/remoteproc/xlnx_r5_remoteproc.c | 6 +++---
>  3 files changed, 5 insertions(+), 5 deletions(-)

For i.MX:

Acked-by: Peng Fan <peng.fan@nxp.com>


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

* Re: [PATCH] remoteproc: Use of_property_present()
  2024-07-31 19:12 [PATCH] remoteproc: Use of_property_present() Rob Herring (Arm)
  2024-08-01  1:51 ` Peng Fan
@ 2024-08-13 15:24 ` Mathieu Poirier
  1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Poirier @ 2024-08-13 15:24 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: Bjorn Andersson, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, linux-remoteproc, imx, linux-arm-kernel,
	linux-kernel

On Wed, Jul 31, 2024 at 01:12:45PM -0600, Rob Herring (Arm) wrote:
> Use of_property_present() to test for property presence rather than
> of_(find|get)_property(). This is part of a larger effort to remove
> callers of of_find_property() and similar functions. of_find_property()
> leaks the DT struct property and data pointers which is a problem for
> dynamically allocated nodes which may be freed.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>  drivers/remoteproc/imx_dsp_rproc.c      | 2 +-
>  drivers/remoteproc/imx_rproc.c          | 2 +-
>  drivers/remoteproc/xlnx_r5_remoteproc.c | 6 +++---
>  3 files changed, 5 insertions(+), 5 deletions(-)
>

I have applied this patch.

Thanks,
Mathieu

> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 087506e21508..376187ad5754 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -509,7 +509,7 @@ static int imx_dsp_rproc_mbox_alloc(struct imx_dsp_rproc *priv)
>  	struct mbox_client *cl;
>  	int ret;
>  
> -	if (!of_get_property(dev->of_node, "mbox-names", NULL))
> +	if (!of_property_present(dev->of_node, "mbox-names"))
>  		return 0;
>  
>  	cl = &priv->cl;
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 144c8e9a642e..8d7ecc809c67 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -807,7 +807,7 @@ static int imx_rproc_xtr_mbox_init(struct rproc *rproc)
>  	if (priv->tx_ch && priv->rx_ch)
>  		return 0;
>  
> -	if (!of_get_property(dev->of_node, "mbox-names", NULL))
> +	if (!of_property_present(dev->of_node, "mbox-names"))
>  		return 0;
>  
>  	cl = &priv->cl;
> diff --git a/drivers/remoteproc/xlnx_r5_remoteproc.c b/drivers/remoteproc/xlnx_r5_remoteproc.c
> index 596f3ffb8935..2cea97c746fd 100644
> --- a/drivers/remoteproc/xlnx_r5_remoteproc.c
> +++ b/drivers/remoteproc/xlnx_r5_remoteproc.c
> @@ -1059,7 +1059,7 @@ static int zynqmp_r5_core_init(struct zynqmp_r5_cluster *cluster,
>  	r5_core = cluster->r5_cores[0];
>  
>  	/* Maintain backward compatibility for zynqmp by using hardcode TCM address. */
> -	if (of_find_property(r5_core->np, "reg", NULL))
> +	if (of_property_present(r5_core->np, "reg"))
>  		ret = zynqmp_r5_get_tcm_node_from_dt(cluster);
>  	else if (device_is_compatible(dev, "xlnx,zynqmp-r5fss"))
>  		ret = zynqmp_r5_get_tcm_node(cluster);
> @@ -1086,7 +1086,7 @@ static int zynqmp_r5_core_init(struct zynqmp_r5_cluster *cluster,
>  			return ret;
>  		}
>  
> -		if (of_find_property(dev_of_node(dev), "xlnx,tcm-mode", NULL) ||
> +		if (of_property_present(dev_of_node(dev), "xlnx,tcm-mode") ||
>  		    device_is_compatible(dev, "xlnx,zynqmp-r5fss")) {
>  			ret = zynqmp_pm_set_tcm_config(r5_core->pm_domain_id,
>  						       tcm_mode);
> @@ -1147,7 +1147,7 @@ static int zynqmp_r5_cluster_init(struct zynqmp_r5_cluster *cluster)
>  		return -EINVAL;
>  	}
>  
> -	if (of_find_property(dev_node, "xlnx,tcm-mode", NULL)) {
> +	if (of_property_present(dev_node, "xlnx,tcm-mode")) {
>  		ret = of_property_read_u32(dev_node, "xlnx,tcm-mode", (u32 *)&tcm_mode);
>  		if (ret)
>  			return ret;
> -- 
> 2.43.0
> 


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

end of thread, other threads:[~2024-08-13 15:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 19:12 [PATCH] remoteproc: Use of_property_present() Rob Herring (Arm)
2024-08-01  1:51 ` Peng Fan
2024-08-13 15:24 ` Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).