* [PATCH] drm: mediatek: Drop unnecessary check for property presence
@ 2024-07-31 20:13 Rob Herring (Arm)
2024-08-01 8:23 ` AngeloGioacchino Del Regno
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rob Herring (Arm) @ 2024-07-31 20:13 UTC (permalink / raw)
To: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: dri-devel, linux-mediatek, linux-kernel, linux-arm-kernel
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.
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
index 634bbba5d43f..07243f372260 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] drm: mediatek: Drop unnecessary check for property presence
2024-07-31 20:13 [PATCH] drm: mediatek: Drop unnecessary check for property presence Rob Herring (Arm)
@ 2024-08-01 8:23 ` AngeloGioacchino Del Regno
2024-08-21 1:54 ` CK Hu (胡俊光)
2024-08-22 14:30 ` Chun-Kuang Hu
2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-08-01 8:23 UTC (permalink / raw)
To: Rob Herring (Arm), Chun-Kuang Hu, Philipp Zabel, David Airlie,
Daniel Vetter, Matthias Brugger
Cc: dri-devel, linux-mediatek, linux-kernel, linux-arm-kernel
Il 31/07/24 22:13, Rob Herring (Arm) ha scritto:
> 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.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: mediatek: Drop unnecessary check for property presence
2024-07-31 20:13 [PATCH] drm: mediatek: Drop unnecessary check for property presence Rob Herring (Arm)
2024-08-01 8:23 ` AngeloGioacchino Del Regno
@ 2024-08-21 1:54 ` CK Hu (胡俊光)
2024-08-22 14:30 ` Chun-Kuang Hu
2 siblings, 0 replies; 4+ messages in thread
From: CK Hu (胡俊光) @ 2024-08-21 1:54 UTC (permalink / raw)
To: robh@kernel.org, p.zabel@pengutronix.de, airlied@gmail.com,
daniel@ffwll.ch, chunkuang.hu@kernel.org,
angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Hi, Rob:
On Wed, 2024-07-31 at 14:13 -0600, Rob Herring (Arm) wrote:
>
> 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.
Reviewed-by: CK Hu <ck.hu@mediatek.com>
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
> index 634bbba5d43f..07243f372260 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drm: mediatek: Drop unnecessary check for property presence
2024-07-31 20:13 [PATCH] drm: mediatek: Drop unnecessary check for property presence Rob Herring (Arm)
2024-08-01 8:23 ` AngeloGioacchino Del Regno
2024-08-21 1:54 ` CK Hu (胡俊光)
@ 2024-08-22 14:30 ` Chun-Kuang Hu
2 siblings, 0 replies; 4+ messages in thread
From: Chun-Kuang Hu @ 2024-08-22 14:30 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Chun-Kuang Hu, Philipp Zabel, David Airlie, Daniel Vetter,
Matthias Brugger, AngeloGioacchino Del Regno, dri-devel,
linux-mediatek, linux-kernel, linux-arm-kernel
Hi, Rob:
Rob Herring (Arm) <robh@kernel.org> 於 2024年8月1日 週四 上午4:14寫道:
>
> 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.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> drivers/gpu/drm/mediatek/mtk_disp_rdma.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
> index 634bbba5d43f..07243f372260 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_rdma.c
> @@ -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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-22 14:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 20:13 [PATCH] drm: mediatek: Drop unnecessary check for property presence Rob Herring (Arm)
2024-08-01 8:23 ` AngeloGioacchino Del Regno
2024-08-21 1:54 ` CK Hu (胡俊光)
2024-08-22 14:30 ` Chun-Kuang Hu
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).