Skip to contentSkip to conversation

media: Use of_property_present() for testing DT property presence

PATCH In review Rob Herring 3 participants 3 messages Mar 10, 2023 – Mar 13, 2023

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

PATCH 1/1 media: 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/media/platform/mediatek/jpeg/mtk_jpeg_core.c        | 2 +-
 drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 +-
 drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c | 2 +-
 drivers/media/platform/xilinx/xilinx-vtc.c                  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +1 -1
index 969516a940ba..1a2b3214b6f8 100644
@@ -1757,7 +1757,7 @@ static int mtk_jpeg_probe(struct platform_device *pdev)
 	jpeg->vdev->device_caps = V4L2_CAP_STREAMING |
 				  V4L2_CAP_VIDEO_M2M_MPLANE;
 
-	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL))
+	if (of_property_present(pdev->dev.of_node, "dma-ranges"))
 		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
 
 	ret = video_register_device(jpeg->vdev, VFL_TYPE_VIDEO, -1);
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +1 -1
index 174a6eec2f54..d2db8ccaa4c0 100644
@@ -321,7 +321,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL)) {
+	if (of_property_present(pdev->dev.of_node, "dma-ranges")) {
 		ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
 		if (ret) {
 			mtk_v4l2_err("Failed to set mask");
drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c +1 -1
index 9095186d5495..199042034a3c 100644
@@ -344,7 +344,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 		goto err_event_workq;
 	}
 
-	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL))
+	if (of_property_present(pdev->dev.of_node, "dma-ranges"))
 		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
 
 	ret = video_register_device(vfd_enc, VFL_TYPE_VIDEO, -1);
drivers/media/platform/xilinx/xilinx-vtc.c +1 -1
index 0ae0208d7529..cb4b421a348d 100644
@@ -254,7 +254,7 @@ struct xvtc_device *xvtc_of_get(struct device_node *np)
 	struct xvtc_device *found = NULL;
 	struct xvtc_device *xvtc;
 
-	if (!of_find_property(np, "xlnx,vtc", NULL))
+	if (!of_property_present(np, "xlnx,vtc"))
 		return NULL;
 
 	xvtc_node = of_parse_phandle(np, "xlnx,vtc", 0);
Signature · 1 line
2.39.2
maintainer 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 59 lines
---
 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c        | 2 +-
 drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 +-
 drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c | 2 +-
 drivers/media/platform/xilinx/xilinx-vtc.c                  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +1 -1
index 969516a940ba..1a2b3214b6f8 100644
@@ -1757,7 +1757,7 @@ static int mtk_jpeg_probe(struct platform_device *pdev)
 	jpeg->vdev->device_caps = V4L2_CAP_STREAMING |
 				  V4L2_CAP_VIDEO_M2M_MPLANE;
 
-	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL))
+	if (of_property_present(pdev->dev.of_node, "dma-ranges"))
 		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
 
 	ret = video_register_device(jpeg->vdev, VFL_TYPE_VIDEO, -1);
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +1 -1
index 174a6eec2f54..d2db8ccaa4c0 100644
@@ -321,7 +321,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL)) {
+	if (of_property_present(pdev->dev.of_node, "dma-ranges")) {
 		ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
 		if (ret) {
 			mtk_v4l2_err("Failed to set mask");
drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c +1 -1
index 9095186d5495..199042034a3c 100644
@@ -344,7 +344,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 		goto err_event_workq;
 	}
 
-	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL))
+	if (of_property_present(pdev->dev.of_node, "dma-ranges"))
 		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
 
 	ret = video_register_device(vfd_enc, VFL_TYPE_VIDEO, -1);
drivers/media/platform/xilinx/xilinx-vtc.c +1 -1
index 0ae0208d7529..cb4b421a348d 100644
@@ -254,7 +254,7 @@ struct xvtc_device *xvtc_of_get(struct device_node *np)
 	struct xvtc_device *found = NULL;
 	struct xvtc_device *xvtc;
 
-	if (!of_find_property(np, "xlnx,vtc", NULL))
+	if (!of_property_present(np, "xlnx,vtc"))
 		return NULL;
 
 	xvtc_node = of_parse_phandle(np, "xlnx,vtc", 0);
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Rob Herring

Il 10/03/23 15:47, Rob Herring ha scritto:

Quoted 8 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.

For MTK JPEG, MTK vcodec