diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c index 433c080197a2..4f84825fddca 100644 --- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c @@ -261,12 +261,10 @@ 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 drm_bridge *next_bridge[PL_MAX_NEXT_BRIDGES]; + struct drm_bridge *selected_bridge = NULL; u32 port_id; bool found_port = false; - int reg, ep_cnt = 0; - /* select the first next bridge by default */ - int bridge_sel = 0; + int reg; for (port_id = 1; port_id <= PL_MAX_MST_ADDR + 1; port_id++) { port = of_graph_get_port_by_id(np, port_id); @@ -300,24 +298,25 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl) continue; } - next_bridge[ep_cnt] = of_drm_find_bridge(remote); - if (!next_bridge[ep_cnt]) { + struct drm_bridge *next_bridge = of_drm_find_bridge(remote); + if (!next_bridge) { of_node_put(remote); return ERR_PTR(-EPROBE_DEFER); } - /* specially select the next bridge with companion PXL2DPI */ - if (of_property_present(remote, "fsl,companion-pxl2dpi")) - bridge_sel = ep_cnt; - - ep_cnt++; + /* + * Select the next bridge with companion PXL2DPI if + * present, otherwise default to the first bridge + */ + if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2dpi")) + selected_bridge = next_bridge; of_node_put(remote); } pl->mst_addr = port_id - 1; - return next_bridge[bridge_sel]; + return selected_bridge; } static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)