Skip to contentSkip to conversation

drm: mediatek: Drop unnecessary check for property presence

PATCH Applied Rob Herring (Arm) 4 participants 4 messages Jul 31, 2024 – Aug 22, 2024

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

PATCH 1/1 drm: mediatek: Drop unnecessary check for property presence

of_property_read_u32() returns -EINVAL if a property is not present, so the preceeding check for presence with of_find_property() can be dropped. Really, what the errno is shouldn't matter. Either the property can be read and used or it can't and is ignored.

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.

---
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_rdma.c +5 -8
index 634bbba5d43f..07243f372260 100644
@@ -341,14 +341,11 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
 		dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
 #endif
 
-	if (of_find_property(dev->of_node, "mediatek,rdma-fifo-size", &ret)) {
-		ret = of_property_read_u32(dev->of_node,
-					   "mediatek,rdma-fifo-size",
-					   &priv->fifo_size);
-		if (ret)
-			return dev_err_probe(dev, ret,
-					     "Failed to get rdma fifo size\n");
-	}
+	ret = of_property_read_u32(dev->of_node,
+				   "mediatek,rdma-fifo-size",
+				   &priv->fifo_size);
+	if (ret && (ret != -EINVAL))
+		return dev_err_probe(dev, ret, "Failed to get rdma fifo size\n");
 
 	/* Disable and clear pending interrupts */
 	writel(0x0, priv->regs + DISP_REG_RDMA_INT_ENABLE);
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Il 31/07/24 22:13, Rob Herring (Arm) ha scritto:

Quoted 11 lines

of_property_read_u32() returns -EINVAL if a property is not present, so the preceeding check for presence with of_find_property() can be dropped. Really, what the errno is shouldn't matter. Either the property can be read and used or it can't and is ignored.

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.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Rob Herring (Arm)

Hi, Rob:

Quoted 11 lines · Rob Herring (Arm)

External email : Please do not click links or open attachments until you have verified the sender or the content.
of_property_read_u32() returns -EINVAL if a property is not present, so
the preceeding check for presence with of_find_property() can be
dropped. Really, what the errno is shouldn't matter. Either the property
can be read and used or it can't and is ignored.

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.

Quoted 32 lines
---
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_rdma.c +5 -8
index 634bbba5d43f..07243f372260 100644
@@ -341,14 +341,11 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
 		dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
 #endif
 
-	if (of_find_property(dev->of_node, "mediatek,rdma-fifo-size", &ret)) {
-		ret = of_property_read_u32(dev->of_node,
-					   "mediatek,rdma-fifo-size",
-					   &priv->fifo_size);
-		if (ret)
-			return dev_err_probe(dev, ret,
-					     "Failed to get rdma fifo size\n");
-	}
+	ret = of_property_read_u32(dev->of_node,
+				   "mediatek,rdma-fifo-size",
+				   &priv->fifo_size);
+	if (ret && (ret != -EINVAL))
+		return dev_err_probe(dev, ret, "Failed to get rdma fifo size\n");
 
 	/* Disable and clear pending interrupts */
 	writel(0x0, priv->regs + DISP_REG_RDMA_INT_ENABLE);
Signature · 1 line
2.43.0
maintainer Applied
#3 lore raw
In reply to Rob Herring (Arm)

Hi, Rob:

Rob Herring (Arm) <[email protected]> 於 2024年8月1日 週四 上午4:14寫道:

Quoted 10 lines

of_property_read_u32() returns -EINVAL if a property is not present, so the preceeding check for presence with of_find_property() can be dropped. Really, what the errno is shouldn't matter. Either the property can be read and used or it can't and is ignored.

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.

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

Quoted 33 lines
---
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_rdma.c +5 -9
index 634bbba5d43f..07243f372260 100644
@@ -341,14 +341,11 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
                dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
 #endif
 
-       if (of_find_property(dev->of_node, "mediatek,rdma-fifo-size", &ret)) {
-               ret = of_property_read_u32(dev->of_node,
-                                          "mediatek,rdma-fifo-size",
-                                          &priv->fifo_size);
-               if (ret)
-                       return dev_err_probe(dev, ret,
-                                            "Failed to get rdma fifo size\n");
-       }
+       ret = of_property_read_u32(dev->of_node,
+                                  "mediatek,rdma-fifo-size",
+                                  &priv->fifo_size);
+       if (ret && (ret != -EINVAL))
+               return dev_err_probe(dev, ret, "Failed to get rdma fifo size\n");
 
        /* Disable and clear pending interrupts */
        writel(0x0, priv->regs + DISP_REG_RDMA_INT_ENABLE);
--

2.43.0