[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240823092053.3170445-4-ruanjinjie@huawei.com>
Date: Fri, 23 Aug 2024 17:20:51 +0800
From: Jinjie Ruan <ruanjinjie@...wei.com>
To: <hjc@...k-chips.com>, <heiko@...ech.de>, <andy.yan@...k-chips.com>,
<maarten.lankhorst@...ux.intel.com>, <mripard@...nel.org>,
<tzimmermann@...e.de>, <airlied@...il.com>, <daniel@...ll.ch>,
<dri-devel@...ts.freedesktop.org>, <linux-arm-kernel@...ts.infradead.org>,
<linux-rockchip@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<krzk@...nel.org>, <jic23@...nel.org>
CC: <ruanjinjie@...wei.com>
Subject: [PATCH -next 3/5] drm: of: Use for_each_child_of_node_scoped()
Avoids the need for manual cleanup of_node_put() in early exits
from the loop.
Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
---
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
Powered by blists - more mailing lists