]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/bridge: imx8qxp-pixel-link: simplify freeing of the remote device_node
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 7 Jan 2026 09:56:27 +0000 (10:56 +0100)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Thu, 29 Jan 2026 17:44:03 +0000 (18:44 +0100)
The main loop in imx8qxp_pixel_link_find_next_bridge() requires calling
of_node_put() in multiple places, complicating code flow. Simplify it by
using a cleanup action and making the 'remote' variable scope local to the
loop.

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Liu Ying <victor.liu@nxp.com>
Link: https://patch.msgid.link/20260107-drm-bridge-alloc-getput-drm_of_find_bridge-v4-2-a62b4399a6bf@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c

index 4f84825fddca9751305e82ab55dcac81b191e552..0c5ed06eee1b865e6e39ca7cce4a44993513410a 100644 (file)
@@ -260,7 +260,7 @@ static struct drm_bridge *
 imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
 {
        struct device_node *np = pl->dev->of_node;
-       struct device_node *port, *remote;
+       struct device_node *port;
        struct drm_bridge *selected_bridge = NULL;
        u32 port_id;
        bool found_port = false;
@@ -286,7 +286,8 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
        }
 
        for (reg = 0; reg < PL_MAX_NEXT_BRIDGES; reg++) {
-               remote = of_graph_get_remote_node(np, port_id, reg);
+               struct device_node *remote __free(device_node) =
+                       of_graph_get_remote_node(np, port_id, reg);
                if (!remote)
                        continue;
 
@@ -294,15 +295,12 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
                        DRM_DEV_DEBUG(pl->dev,
                                      "port%u endpoint%u remote parent is not available\n",
                                      port_id, reg);
-                       of_node_put(remote);
                        continue;
                }
 
                struct drm_bridge *next_bridge = of_drm_find_bridge(remote);
-               if (!next_bridge) {
-                       of_node_put(remote);
+               if (!next_bridge)
                        return ERR_PTR(-EPROBE_DEFER);
-               }
 
                /*
                 * Select the next bridge with companion PXL2DPI if
@@ -310,8 +308,6 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
                 */
                if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2dpi"))
                        selected_bridge = next_bridge;
-
-               of_node_put(remote);
        }
 
        pl->mst_addr = port_id - 1;