From nobody Mon Dec 1 22:37:17 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9462132E755 for ; Fri, 28 Nov 2025 16:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764348923; cv=none; b=TCRKEkEocYnTcORKZ5NV0oOYCTSpMEau/fhAIkvAgomPIUA30ryxIBrqlDB4gNJoC0A89SbhWDl+HGmvl5675fk8L7rl+FFY3cXsn2WHgLPj6+TwKkH3WdsYQRR/55Xk1NSCWjICrpaupch/7t7kiSpHJ1CtzbmxzvGQSP1aYLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764348923; c=relaxed/simple; bh=fQu/W+0tolr6+U6fRt83IgC2NQt38kvoADgiW4WR5Hc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hfd6CBUOTytIuGV51HJQL+/fYPXmyT9YLhRbzoWOmbPWBQSDMJ/BG85LLSIwteegQ9TvB4CZYMUPMVHUR3E6Hfn8ZkhcxqU9p+p0AEeovUY2cBDIneVnwzaZILWQHx+3unPivuAyQW0b0Td2YKxTp4kpY42sS4Da70tNnE08DBQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=YVI71PvC; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="YVI71PvC" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 379AF4E4194E; Fri, 28 Nov 2025 16:55:20 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0357F60706; Fri, 28 Nov 2025 16:55:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E9BF110B02187; Fri, 28 Nov 2025 17:55:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764348916; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=4KsAxr99sySjsHY4TzPD3tHVsqK24nvaf2pqUbhtfhE=; b=YVI71PvCVzgmOQp16UtVOf8VdYpNuV79FTjRiPbKsJQVTVyqxnuaeM/dgMAH35gLARG0Ur 1Uo4a1yenzCCTwAvRHXyLb5t/Rmdw1mGAZe87wHcoDmGz617/QiKXdKvBE9cs6Col4akJ+ Sodw7fGjEiMNJ5qzy5mEi9yEblzwZEba0n/ElagD7LGnlbj1lFGrjffZ5mIcTaZPsX+Oig EuEdtbZ82quA3LNem2FG01OQuh35riUzwR02oZr3xZ86V0H6E8ylboKLFqt04tIT4Pp9wk gIUSG1ZlG1djqE9oSZETMCjG8DqUEXAChf0Dqp1nsN+Zr6DtAmcLcyS1jcxNdg== From: Luca Ceresoli Date: Fri, 28 Nov 2025 17:50:34 +0100 Subject: [PATCH v2 24/26] drm/bridge: imx8qxp-pixel-link: simplify logic to find next bridge Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251128-drm-bridge-alloc-getput-drm_of_find_bridge-v2-24-88f8a107eca2@bootlin.com> References: <20251128-drm-bridge-alloc-getput-drm_of_find_bridge-v2-0-88f8a107eca2@bootlin.com> In-Reply-To: <20251128-drm-bridge-alloc-getput-drm_of_find_bridge-v2-0-88f8a107eca2@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jonathan Corbet , Alexey Brodkin , Phong LE , Liu Ying , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Adrien Grassein , Laurent Pinchart , Tomi Valkeinen , Kieran Bingham , Geert Uytterhoeven , Magnus Damm , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Chun-Kuang Hu , Philipp Zabel , Matthias Brugger , AngeloGioacchino Del Regno , Anitha Chrisanthus , Inki Dae , Seung-Woo Kim , Kyungmin Park , Krzysztof Kozlowski , Alim Akhtar Cc: Hui Pu , Thomas Petazzoni , Louis Chauvet , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 imx8qxp_pixel_link_find_next_bridge() uses a sophisticated logic to find the preferred next bridge, using an array with two supporting index variables. This is more sophisticated than required because we only ever need a pointer to the "current" bridge and to the "best so far" bridge. Additionally this logic is going to make the addition of proper refcounting quite complex. Rewrite the logic using two drm_bridge pointers, which is by itself slightly simpler and is a preparation step for introducing bridge refcounting in a later commit. Also reword a comment to make it clearer. Signed-off-by: Luca Ceresoli --- Cc: Liu Ying --- drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 23 +++++++++++----------= -- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/= drm/bridge/imx/imx8qxp-pixel-link.c index e5943506981d..53016f0d53a0 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_pi= xel_link *pl) { struct device_node *np =3D pl->dev->of_node; struct device_node *port, *remote; - struct drm_bridge *next_bridge[PL_MAX_NEXT_BRIDGES]; + struct drm_bridge *selected_bridge =3D NULL; u32 port_id; bool found_port =3D false; - int reg, ep_cnt =3D 0; - /* select the first next bridge by default */ - int bridge_sel =3D 0; + int reg; =20 for (port_id =3D 1; port_id <=3D PL_MAX_MST_ADDR + 1; port_id++) { port =3D of_graph_get_port_by_id(np, port_id); @@ -300,24 +298,25 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pi= xel_link *pl) continue; } =20 - next_bridge[ep_cnt] =3D of_drm_find_bridge(remote); - if (!next_bridge[ep_cnt]) { + struct drm_bridge *next_bridge =3D of_drm_find_bridge(remote); + if (!next_bridge) { of_node_put(remote); return ERR_PTR(-EPROBE_DEFER); } =20 - /* specially select the next bridge with companion PXL2DPI */ - if (of_property_present(remote, "fsl,companion-pxl2dpi")) - bridge_sel =3D 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-pxl2d= pi")) + selected_bridge =3D next_bridge; =20 of_node_put(remote); } =20 pl->mst_addr =3D port_id - 1; =20 - return next_bridge[bridge_sel]; + return selected_bridge; } =20 static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev) --=20 2.51.1