[PATCH -next v2] drm: of: Use for_each_child_of_node_scoped()
Jinjie Ruan
ruanjinjie at huawei.com
Fri Aug 30 07:40:09 UTC 2024
Avoids the need for manual cleanup of_node_put() in early exits
from the loop.
Signed-off-by: Jinjie Ruan <ruanjinjie at huawei.com>
---
v2:
- Split out from the PATCH set.
---
drivers/gpu/drm/drm_of.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 177b600895d3..41d9288c97a7 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -304,10 +304,9 @@ static int drm_of_lvds_get_port_pixels_type(struct device_node *port_node)
static int drm_of_lvds_get_remote_pixels_type(
const struct device_node *port_node)
{
- struct device_node *endpoint = NULL;
int pixels_type = -EPIPE;
- for_each_child_of_node(port_node, endpoint) {
+ for_each_child_of_node_scoped(port_node, endpoint) {
struct device_node *remote_port;
int current_pt;
@@ -315,10 +314,8 @@ static int drm_of_lvds_get_remote_pixels_type(
continue;
remote_port = of_graph_get_remote_port(endpoint);
- if (!remote_port) {
- of_node_put(endpoint);
+ if (!remote_port)
return -EPIPE;
- }
current_pt = drm_of_lvds_get_port_pixels_type(remote_port);
of_node_put(remote_port);
@@ -332,10 +329,8 @@ static int drm_of_lvds_get_remote_pixels_type(
* configurations by passing the endpoints explicitly to
* drm_of_lvds_get_dual_link_pixel_order().
*/
- if (!current_pt || pixels_type != current_pt) {
- of_node_put(endpoint);
+ if (!current_pt || pixels_type != current_pt)
return -EINVAL;
- }
}
return pixels_type;
--
2.34.1
More information about the dri-devel
mailing list