* [PATCH -next v2] drm/rockchip: Use for_each_child_of_node_scoped()
@ 2024-08-30 7:34 Jinjie Ruan
2024-09-19 15:11 ` Heiko Stuebner
0 siblings, 1 reply; 2+ messages in thread
From: Jinjie Ruan @ 2024-08-30 7:34 UTC (permalink / raw)
To: hjc, heiko, andy.yan, maarten.lankhorst, mripard, tzimmermann,
airlied, daniel, dri-devel, linux-arm-kernel, linux-rockchip
Cc: ruanjinjie
Avoids the need for manual cleanup of_node_put() in early exits
from the loop.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
---
v2:
- Add Reviewed-by.
- Split out from the PATCH set.
---
drivers/gpu/drm/rockchip/rockchip_lvds.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
index 9a01aa450741..f5b3f18794dd 100644
--- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -548,7 +548,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
struct drm_encoder *encoder;
struct drm_connector *connector;
struct device_node *remote = NULL;
- struct device_node *port, *endpoint;
+ struct device_node *port;
int ret = 0, child_count = 0;
const char *name;
u32 endpoint_id = 0;
@@ -560,15 +560,13 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
"can't found port point, please init lvds panel port!\n");
return -EINVAL;
}
- for_each_child_of_node(port, endpoint) {
+ for_each_child_of_node_scoped(port, endpoint) {
child_count++;
of_property_read_u32(endpoint, "reg", &endpoint_id);
ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id,
&lvds->panel, &lvds->bridge);
- if (!ret) {
- of_node_put(endpoint);
+ if (!ret)
break;
- }
}
if (!child_count) {
DRM_DEV_ERROR(dev, "lvds port does not have any children\n");
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next v2] drm/rockchip: Use for_each_child_of_node_scoped()
2024-08-30 7:34 [PATCH -next v2] drm/rockchip: Use for_each_child_of_node_scoped() Jinjie Ruan
@ 2024-09-19 15:11 ` Heiko Stuebner
0 siblings, 0 replies; 2+ messages in thread
From: Heiko Stuebner @ 2024-09-19 15:11 UTC (permalink / raw)
To: hjc, andy.yan, maarten.lankhorst, mripard, tzimmermann, airlied,
daniel, dri-devel, linux-arm-kernel, linux-rockchip, Jinjie Ruan
Cc: ruanjinjie
Hi,
Am Freitag, 30. August 2024, 09:34:54 CEST schrieb Jinjie Ruan:
> Avoids the need for manual cleanup of_node_put() in early exits
> from the loop.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Heiko Stuebner <heiko@sntech.de>
> ---
> v2:
> - Add Reviewed-by.
> - Split out from the PATCH set.
This patch also appears in your series
"[PATCH -next v2 0/3] drm/rockchip: Simplified with for_each_child_of_node_scoped()"
it seems, so I think you could describe why it was split from there now.
Also patch subject "drm/rockchip: lvds: ...."
Thanks
Heiko
> ---
> drivers/gpu/drm/rockchip/rockchip_lvds.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> index 9a01aa450741..f5b3f18794dd 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> @@ -548,7 +548,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
> struct drm_encoder *encoder;
> struct drm_connector *connector;
> struct device_node *remote = NULL;
> - struct device_node *port, *endpoint;
> + struct device_node *port;
> int ret = 0, child_count = 0;
> const char *name;
> u32 endpoint_id = 0;
> @@ -560,15 +560,13 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
> "can't found port point, please init lvds panel port!\n");
> return -EINVAL;
> }
> - for_each_child_of_node(port, endpoint) {
> + for_each_child_of_node_scoped(port, endpoint) {
> child_count++;
> of_property_read_u32(endpoint, "reg", &endpoint_id);
> ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id,
> &lvds->panel, &lvds->bridge);
> - if (!ret) {
> - of_node_put(endpoint);
> + if (!ret)
> break;
> - }
> }
> if (!child_count) {
> DRM_DEV_ERROR(dev, "lvds port does not have any children\n");
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-19 15:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30 7:34 [PATCH -next v2] drm/rockchip: Use for_each_child_of_node_scoped() Jinjie Ruan
2024-09-19 15:11 ` Heiko Stuebner
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).