From nobody Tue Dec 2 02:30:33 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 CB23835E52A; Wed, 19 Nov 2025 13:09:53 +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=1763557795; cv=none; b=R2hc4iyiy9Xw1VqYceM3jvfJiUTf/lo7tMBlt6i+LdBLNAXNFyRLp307WOH32s4Kq2eZTmU5gEUmci6wVmjI6azqHY/czkm3imezYx3RB/XTge66MpzfZrQ1qNhk3K97mMn7z7+U2GYeZ5BJRzTMOlVLCdpbsvdPNMtwmue9UHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763557795; c=relaxed/simple; bh=5cuWxFruSbmINQkfu8xBEDBSefUx4G9GS7gD5IXtbMQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GNfY0b2QyILeavvfmzGFm2T0Mod+X3QUuzvwyZxyOeAPYR0Ap44dj/aYrYDwYhqkSRam1GfibKfHWK4C7c0Sx8W495V3q45YKp6/dXRJvBPfFaqHbDAVNmSF7OVM5BG9T0+5f2kOr6RBgeOv6Xs20OIHkGJE0d8/P/GiIlXziwc= 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=OlX/PF+d; 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="OlX/PF+d" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 5E7214E4179C; Wed, 19 Nov 2025 13:09:52 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2F04860699; Wed, 19 Nov 2025 13:09:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D2F8810371A53; Wed, 19 Nov 2025 14:09:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763557790; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=axXT5p39UcLgfeXlnv3r+PQb3eCsVz2C9lrKQC2f4Uk=; b=OlX/PF+dhNGJG27mrsK1i4MNguYEVaaiKq83NP0yOr041d9TgIxWfbA2GyldpQEAfPLd3J wNbvXQz9oBqELh/fqHBdK3mPbEJ3JKZLLabdZdqhqGE7GiQMZKWviSVNIdzuN1DuSJ9D6O ji63oyId+HMuMeLvrrbb9/FhGf8/Vn2JH5T3bED5Ab473KCMMc1GmDK6PMlKKy03bJn35W CR9esGIgCRwjBUdDQ8G/Q3ByDThJhNj95m+NHds8C3IrJVQlptjCCcIy0X+k2qNcCYxnYs 7W0XT05zHAApmNT3EVv8sRDwLVGvyuBhAK9DAMINTmHuHkuNsVeo/QElxQso7A== From: Luca Ceresoli Date: Wed, 19 Nov 2025 14:05:57 +0100 Subject: [PATCH 26/26] drm/bridge: imx8qxp-pixel-link: convert to drm_of_find_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: <20251119-drm-bridge-alloc-getput-drm_of_find_bridge-v1-26-0db98a7fe474@bootlin.com> References: <20251119-drm-bridge-alloc-getput-drm_of_find_bridge-v1-0-0db98a7fe474@bootlin.com> In-Reply-To: <20251119-drm-bridge-alloc-getput-drm_of_find_bridge-v1-0-0db98a7fe474@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 , Edmund Dea , Inki Dae , Seung-Woo Kim , Kyungmin Park , Krzysztof Kozlowski , Alim Akhtar Cc: Hui Pu , Thomas Petazzoni , 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 of_drm_find_bridge() is deprecated. Move to its replacement drm_of_find_bridge() which gets a bridge reference, and put it when done. This needs to be handled in various steps: * the bridge returned drm_of_find_bridge() is stored in next_bridge whose scope is the for loop, so a cleanup action is enough * the value of next_bridge is copied into selected_bridge, potentially more than once, so a cleanup action at function scope is useful here too * however on successful return selected_bridge must be returned and ultimately stored, so it should not be put in that case: use return_ptr() to defuse the cleanup action on successful return * finally, put the bridge reference on device remove Signed-off-by: Luca Ceresoli --- Cc: Liu Ying --- drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/= drm/bridge/imx/imx8qxp-pixel-link.c index 2ecc3c1051e5..9818239cf6e7 100644 --- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c @@ -256,12 +256,13 @@ static int imx8qxp_pixel_link_disable_all_controls(st= ruct imx8qxp_pixel_link *pl return imx8qxp_pixel_link_disable_sync(pl); } =20 +/* The returned bridge has its refcount incremented */ static struct drm_bridge * imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl) { struct device_node *np =3D pl->dev->of_node; struct device_node *port; - struct drm_bridge *selected_bridge =3D NULL; + struct drm_bridge *selected_bridge __free(drm_bridge_put) =3D NULL; u32 port_id; bool found_port =3D false; int reg; @@ -298,7 +299,7 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixe= l_link *pl) continue; } =20 - struct drm_bridge *next_bridge =3D of_drm_find_bridge(remote); + struct drm_bridge *next_bridge __free(drm_bridge_put) =3D drm_of_find_br= idge(remote); if (!next_bridge) return ERR_PTR(-EPROBE_DEFER); =20 @@ -306,13 +307,15 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pi= xel_link *pl) * 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; + if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2d= pi")) { + drm_bridge_put(selected_bridge); + selected_bridge =3D drm_bridge_get(next_bridge); + } } =20 pl->mst_addr =3D port_id - 1; =20 - return selected_bridge; + return_ptr(selected_bridge); } =20 static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev) @@ -392,6 +395,7 @@ static void imx8qxp_pixel_link_bridge_remove(struct pla= tform_device *pdev) struct imx8qxp_pixel_link *pl =3D platform_get_drvdata(pdev); =20 drm_bridge_remove(&pl->bridge); + drm_bridge_put(pl->next_bridge); } =20 static const struct of_device_id imx8qxp_pixel_link_dt_ids[] =3D { --=20 2.51.1