[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251119-drm-bridge-alloc-getput-drm_of_find_bridge-v1-26-0db98a7fe474@bootlin.com>
Date: Wed, 19 Nov 2025 14:05:57 +0100
From: Luca Ceresoli <luca.ceresoli@...tlin.com>
To: Andrzej Hajda <andrzej.hajda@...el.com>,
Neil Armstrong <neil.armstrong@...aro.org>, Robert Foss <rfoss@...nel.org>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
Jonas Karlman <jonas@...boo.se>, Jernej Skrabec <jernej.skrabec@...il.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Jonathan Corbet <corbet@....net>, Alexey Brodkin <abrodkin@...opsys.com>,
Phong LE <ple@...libre.com>, Liu Ying <victor.liu@....com>,
Shawn Guo <shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
Adrien Grassein <adrien.grassein@...il.com>,
Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
Tomi Valkeinen <tomi.valkeinen+renesas@...asonboard.com>,
Kieran Bingham <kieran.bingham+renesas@...asonboard.com>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Magnus Damm <magnus.damm@...il.com>, Kevin Hilman <khilman@...libre.com>,
Jerome Brunet <jbrunet@...libre.com>,
Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
Chun-Kuang Hu <chunkuang.hu@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
Anitha Chrisanthus <anitha.chrisanthus@...el.com>,
Edmund Dea <edmund.j.dea@...el.com>, Inki Dae <inki.dae@...sung.com>,
Seung-Woo Kim <sw0312.kim@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>,
Krzysztof Kozlowski <krzk@...nel.org>,
Alim Akhtar <alim.akhtar@...sung.com>
Cc: Hui Pu <Hui.Pu@...ealthcare.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, imx@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, linux-renesas-soc@...r.kernel.org,
linux-amlogic@...ts.infradead.org, linux-mediatek@...ts.infradead.org,
linux-samsung-soc@...r.kernel.org,
Luca Ceresoli <luca.ceresoli@...tlin.com>
Subject: [PATCH 26/26] drm/bridge: imx8qxp-pixel-link: convert to
drm_of_find_bridge()
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 <luca.ceresoli@...tlin.com>
---
Cc: Liu Ying <victor.liu@....com>
---
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(struct imx8qxp_pixel_link *pl
return imx8qxp_pixel_link_disable_sync(pl);
}
+/* 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 = pl->dev->of_node;
struct device_node *port;
- struct drm_bridge *selected_bridge = NULL;
+ struct drm_bridge *selected_bridge __free(drm_bridge_put) = NULL;
u32 port_id;
bool found_port = false;
int reg;
@@ -298,7 +299,7 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
continue;
}
- struct drm_bridge *next_bridge = of_drm_find_bridge(remote);
+ struct drm_bridge *next_bridge __free(drm_bridge_put) = drm_of_find_bridge(remote);
if (!next_bridge)
return ERR_PTR(-EPROBE_DEFER);
@@ -306,13 +307,15 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_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-pxl2dpi"))
- selected_bridge = next_bridge;
+ if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2dpi")) {
+ drm_bridge_put(selected_bridge);
+ selected_bridge = drm_bridge_get(next_bridge);
+ }
}
pl->mst_addr = port_id - 1;
- return selected_bridge;
+ return_ptr(selected_bridge);
}
static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev)
@@ -392,6 +395,7 @@ static void imx8qxp_pixel_link_bridge_remove(struct platform_device *pdev)
struct imx8qxp_pixel_link *pl = platform_get_drvdata(pdev);
drm_bridge_remove(&pl->bridge);
+ drm_bridge_put(pl->next_bridge);
}
static const struct of_device_id imx8qxp_pixel_link_dt_ids[] = {
--
2.51.1
Powered by blists - more mailing lists