Skip to contentSkip to conversation

drm: Use of_property_present() for testing DT property presence

PATCH In review Rob Herring 5 participants 5 messages Mar 10, 2023 – Mar 14, 2023

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Use of_property_present() for testing DT property presence

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 2 +-
 drivers/gpu/drm/drm_mipi_dsi.c                  | 2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c         | 2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           | 2 +-
 drivers/gpu/drm/sun4i/sun8i_mixer.c             | 2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +1 -1
index 9e5f2b4dc2e5..fab139b324af 100644
@@ -313,7 +313,7 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 		}
 
 		/* specially select the next bridge with companion PXL2DPI */
-		if (of_find_property(remote, "fsl,companion-pxl2dpi", NULL))
+		if (of_property_present(remote, "fsl,companion-pxl2dpi"))
 			bridge_sel = ep_cnt;
 
 		ep_cnt++;
drivers/gpu/drm/drm_mipi_dsi.c +1 -1
index b41aaf2bb9f1..7900a4707d7c 100644
@@ -329,7 +329,7 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)
 
 	for_each_available_child_of_node(host->dev->of_node, node) {
 		/* skip nodes without reg property */
-		if (!of_find_property(node, "reg", NULL))
+		if (!of_property_present(node, "reg"))
 			continue;
 		of_mipi_dsi_device_add(host, node);
 	}
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -1
index ce6b76c45b6f..2359dca80492 100644
@@ -964,7 +964,7 @@ static void adreno_get_pwrlevels(struct device *dev,
 	gpu->fast_rate = 0;
 
 	/* You down with OPP? */
-	if (!of_find_property(dev->of_node, "operating-points-v2", NULL))
+	if (!of_property_present(dev->of_node, "operating-points-v2"))
 		ret = adreno_get_legacy_pwrlevels(dev);
 	else {
 		ret = devm_pm_opp_of_add_table(dev);
drivers/gpu/drm/sun4i/sun4i_backend.c +1 -1
index 38070fc261f3..b11dbd50d73e 100644
@@ -792,7 +792,7 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
 	dev_set_drvdata(dev, backend);
 	spin_lock_init(&backend->frontend_lock);
 
-	if (of_find_property(dev->of_node, "interconnects", NULL)) {
+	if (of_property_present(dev->of_node, "interconnects")) {
 		/*
 		 * This assume we have the same DMA constraints for all our the
 		 * devices in our pipeline (all the backends, but also the
drivers/gpu/drm/sun4i/sun8i_mixer.c +1 -1
index bafee05f6b24..11d5244a5aa5 100644
@@ -391,7 +391,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
 	mixer->engine.ops = &sun8i_engine_ops;
 	mixer->engine.node = dev->of_node;
 
-	if (of_find_property(dev->of_node, "iommus", NULL)) {
+	if (of_property_present(dev->of_node, "iommus")) {
 		/*
 		 * This assume we have the same DMA constraints for
 		 * all our the mixers in our pipeline. This sounds
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -1
index ea22c9bf223a..bec1e0cdddb3 100644
@@ -3018,7 +3018,7 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
 	struct device *dev = &pdev->dev;
 	int ret;
 
-	if (!of_find_property(dev->of_node, "interrupts", NULL)) {
+	if (!of_property_present(dev->of_node, "interrupts")) {
 		dev_warn(dev, "'interrupts' DT property is missing, no CEC\n");
 		return 0;
 	}
Signature · 1 line
2.39.2
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Rob,

Thank you for the patch.

Quoted 8 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

Quoted 87 lines
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 2 +-
 drivers/gpu/drm/drm_mipi_dsi.c                  | 2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c         | 2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           | 2 +-
 drivers/gpu/drm/sun4i/sun8i_mixer.c             | 2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +1 -1
index 9e5f2b4dc2e5..fab139b324af 100644
@@ -313,7 +313,7 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 		}
 
 		/* specially select the next bridge with companion PXL2DPI */
-		if (of_find_property(remote, "fsl,companion-pxl2dpi", NULL))
+		if (of_property_present(remote, "fsl,companion-pxl2dpi"))
 			bridge_sel = ep_cnt;
 
 		ep_cnt++;
drivers/gpu/drm/drm_mipi_dsi.c +1 -1
index b41aaf2bb9f1..7900a4707d7c 100644
@@ -329,7 +329,7 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)
 
 	for_each_available_child_of_node(host->dev->of_node, node) {
 		/* skip nodes without reg property */
-		if (!of_find_property(node, "reg", NULL))
+		if (!of_property_present(node, "reg"))
 			continue;
 		of_mipi_dsi_device_add(host, node);
 	}
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -1
index ce6b76c45b6f..2359dca80492 100644
@@ -964,7 +964,7 @@ static void adreno_get_pwrlevels(struct device *dev,
 	gpu->fast_rate = 0;
 
 	/* You down with OPP? */
-	if (!of_find_property(dev->of_node, "operating-points-v2", NULL))
+	if (!of_property_present(dev->of_node, "operating-points-v2"))
 		ret = adreno_get_legacy_pwrlevels(dev);
 	else {
 		ret = devm_pm_opp_of_add_table(dev);
drivers/gpu/drm/sun4i/sun4i_backend.c +1 -1
index 38070fc261f3..b11dbd50d73e 100644
@@ -792,7 +792,7 @@ static int sun4i_backend_bind(struct device *dev, struct device *master,
 	dev_set_drvdata(dev, backend);
 	spin_lock_init(&backend->frontend_lock);
 
-	if (of_find_property(dev->of_node, "interconnects", NULL)) {
+	if (of_property_present(dev->of_node, "interconnects")) {
 		/*
 		 * This assume we have the same DMA constraints for all our the
 		 * devices in our pipeline (all the backends, but also the
drivers/gpu/drm/sun4i/sun8i_mixer.c +1 -1
index bafee05f6b24..11d5244a5aa5 100644
@@ -391,7 +391,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master,
 	mixer->engine.ops = &sun8i_engine_ops;
 	mixer->engine.node = dev->of_node;
 
-	if (of_find_property(dev->of_node, "iommus", NULL)) {
+	if (of_property_present(dev->of_node, "iommus")) {
 		/*
 		 * This assume we have the same DMA constraints for
 		 * all our the mixers in our pipeline. This sounds
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -1
index ea22c9bf223a..bec1e0cdddb3 100644
@@ -3018,7 +3018,7 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
 	struct device *dev = &pdev->dev;
 	int ret;
 
-	if (!of_find_property(dev->of_node, "interrupts", NULL)) {
+	if (!of_property_present(dev->of_node, "interrupts")) {
 		dev_warn(dev, "'interrupts' DT property is missing, no CEC\n");
 		return 0;
 	}
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v1 1/1
#2 lore raw
In reply to Rob Herring
Quoted 7 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

Quoted 5 lines
---
  drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 2 +-
  drivers/gpu/drm/drm_mipi_dsi.c                  | 2 +-
  drivers/gpu/drm/msm/adreno/adreno_gpu.c         | 2 +-

For msm part:

Quoted 4 lines
  drivers/gpu/drm/sun4i/sun4i_backend.c           | 2 +-
  drivers/gpu/drm/sun4i/sun8i_mixer.c             | 2 +-
  drivers/gpu/drm/vc4/vc4_hdmi.c                  | 2 +-
  6 files changed, 6 insertions(+), 6 deletions(-)
Signature · 2 lines
With best wishes
Dmitry
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Rob Herring
Quoted 10 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 2 +-
Quoted 6 lines
 drivers/gpu/drm/drm_mipi_dsi.c                  | 2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c         | 2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           | 2 +-
 drivers/gpu/drm/sun4i/sun8i_mixer.c             | 2 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c                  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Rob Herring

Dne petek, 10. marec 2023 ob 15:47:05 CET je Rob Herring napisal(a):

Quoted 7 lines

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more.

Quoted 7 lines
---
 drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 2 +-
 drivers/gpu/drm/drm_mipi_dsi.c                  | 2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c         | 2 +-
 drivers/gpu/drm/sun4i/sun4i_backend.c           | 2 +-
 drivers/gpu/drm/sun4i/sun8i_mixer.c             | 2 +-

For sun4i:

Best regards,
Jernej

drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c imx8qxp_pixel_link_find_next_bridge(struct · line 315

Quoted 12 lines
 drivers/gpu/drm/vc4/vc4_hdmi.c                  | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c index 9e5f2b4dc2e5..fab139b324af 100644

drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +0 -0
@@ -313,7 +313,7 @@ imx8qxp_pixel_link_find_next_bridge(struct
 imx8qxp_pixel_link *pl) }
 
 		/* specially select the next bridge with companion 

PXL2DPI */

drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c imx8qxp_pixel_link_find_next_bridge(struct · line 316

Quoted 1 line
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +0 -1
-		if (of_find_property(remote, "fsl,companion-pxl2dpi", 

NULL))

drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c imx8qxp_pixel_link_find_next_bridge(struct · line 316

Quoted 1 line
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +1 -0
+		if (of_property_present(remote, "fsl,companion-

pxl2dpi"))

Quoted 36 lines
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +0 -0
 			bridge_sel = ep_cnt;
 
 		ep_cnt++;
drivers/gpu/drm/drm_mipi_dsi.c +1 -1
index b41aaf2bb9f1..7900a4707d7c 100644
@@ -329,7 +329,7 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)
 
 	for_each_available_child_of_node(host->dev->of_node, node) {
 		/* skip nodes without reg property */
-		if (!of_find_property(node, "reg", NULL))
+		if (!of_property_present(node, "reg"))
 			continue;
 		of_mipi_dsi_device_add(host, node);
 	}
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index ce6b76c45b6f..2359dca80492 100644

drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -1
@@ -964,7 +964,7 @@ static void adreno_get_pwrlevels(struct device *dev,
 	gpu->fast_rate = 0;
 
 	/* You down with OPP? */
-	if (!of_find_property(dev->of_node, "operating-points-v2", NULL))
+	if (!of_property_present(dev->of_node, "operating-points-v2"))
 		ret = adreno_get_legacy_pwrlevels(dev);
 	else {
 		ret = devm_pm_opp_of_add_table(dev);
(quoted diff) +0 -0

b/drivers/gpu/drm/sun4i/sun4i_backend.c index 38070fc261f3..b11dbd50d73e 100644

drivers/gpu/drm/sun4i/sun4i_backend.c static int sun4i_backend_bind(struct device *dev, struct · line 797

Quoted 7 lines
drivers/gpu/drm/sun4i/sun4i_backend.c +1 -1
@@ -792,7 +792,7 @@ static int sun4i_backend_bind(struct device *dev, struct
 device *master, dev_set_drvdata(dev, backend);
 	spin_lock_init(&backend->frontend_lock);
 
-	if (of_find_property(dev->of_node, "interconnects", NULL)) {
+	if (of_property_present(dev->of_node, "interconnects")) {
 		/*
 		 * This assume we have the same DMA constraints for all 

our the

drivers/gpu/drm/sun4i/sun4i_backend.c static int sun4i_backend_bind(struct device *dev, struct · line 798

Quoted 1 line
drivers/gpu/drm/sun4i/sun4i_backend.c +0 -0
 		 * devices in our pipeline (all the backends, but also 

the

Quoted 19 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/sun4i/sun8i_mixer.c index bafee05f6b24..11d5244a5aa5 100644

drivers/gpu/drm/sun4i/sun8i_mixer.c +1 -1
@@ -391,7 +391,7 @@ static int sun8i_mixer_bind(struct device *dev, struct
 device *master, mixer->engine.ops = &sun8i_engine_ops;
 	mixer->engine.node = dev->of_node;
 
-	if (of_find_property(dev->of_node, "iommus", NULL)) {
+	if (of_property_present(dev->of_node, "iommus")) {
 		/*
 		 * This assume we have the same DMA constraints for
 		 * all our the mixers in our pipeline. This sounds
drivers/gpu/drm/vc4/vc4_hdmi.c +0 -0
index ea22c9bf223a..bec1e0cdddb3 100644

drivers/gpu/drm/vc4/vc4_hdmi.c static int vc4_hdmi_cec_init(struct vc4_hdmi · line 3022

Quoted 6 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -1
@@ -3018,7 +3018,7 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi
 *vc4_hdmi) struct device *dev = &pdev->dev;
 	int ret;
 
-	if (!of_find_property(dev->of_node, "interrupts", NULL)) {
+	if (!of_property_present(dev->of_node, "interrupts")) {
 		dev_warn(dev, "'interrupts' DT property is missing, no 

CEC\n");

Quoted 2 lines
drivers/gpu/drm/vc4/vc4_hdmi.c +0 -0
 		return 0;
 	}