summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ceresoli <luca.ceresoli@bootlin.com>2026-02-12 00:39:49 +0300
committerLiu Ying <victor.liu@nxp.com>2026-02-25 05:55:24 +0300
commitb99deb6157a13098223f551570c8d11545def0f4 (patch)
treeb52857752216abba391081f863c7f69e3ee561cd
parent645186bf86932c6b9deed2e564cffd09576ba9a4 (diff)
downloadlinux-b99deb6157a13098223f551570c8d11545def0f4.tar.xz
drm/bridge: imx8qxp-pixel-link: get/put the next bridge
This driver obtains a bridge pointer from of_drm_find_bridge() in the probe function and stores it until driver removal. of_drm_find_bridge() is deprecated, so move to of_drm_find_and_get_bridge() for the bridge to be refcounted and use bridge->next_bridge to put the reference on deallocation. To keep the code as simple and reliable as possible remove the intermediate next_bridge and selected_bridge variables. Get/put operations on the remaining pointer is pl->bridge.next_bridge, which is tied to the struct imx8qxp_pixel_link lifetime, are: - get reference when assigned (by of_drm_find_and_get_bridge()) - put reference before reassignment if reassignment happens - put reference when the struct imx8qxp_pixel_link embedding the struct drm_bridge is destroyed (struct drm_bridge::next_bridge) Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Acked-by: Liu Ying <victor.liu@nxp.com> Signed-off-by: Liu Ying <victor.liu@nxp.com> Link: https://lore.kernel.org/r/20260211-drm-bridge-alloc-getput-drm_of_find_bridge-v6-1-651ddfd13bdb@bootlin.com
-rw-r--r--drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
index 6e43a78b02f1..63a8d8b1f76b 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c
@@ -23,7 +23,6 @@
struct imx8qxp_pixel_link {
struct drm_bridge bridge;
- struct drm_bridge *next_bridge;
struct device *dev;
struct imx_sc_ipc *ipc_handle;
u8 stream_id;
@@ -140,7 +139,7 @@ static int imx8qxp_pixel_link_bridge_attach(struct drm_bridge *bridge,
}
return drm_bridge_attach(encoder,
- pl->next_bridge, bridge,
+ pl->bridge.next_bridge, bridge,
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
}
@@ -260,7 +259,6 @@ static int 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;
u32 port_id;
bool found_port = false;
int reg;
@@ -297,20 +295,21 @@ static int imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl)
continue;
}
- struct drm_bridge *next_bridge = of_drm_find_bridge(remote);
- if (!next_bridge)
- return -EPROBE_DEFER;
-
- /*
- * 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 (!pl->bridge.next_bridge) {
+ /* Select the first bridge by default... */
+ pl->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
+ if (!pl->bridge.next_bridge)
+ return -EPROBE_DEFER;
+ } else if (of_property_present(remote, "fsl,companion-pxl2dpi")) {
+ /* ... but prefer the companion PXL2DPI if present */
+ drm_bridge_put(pl->bridge.next_bridge);
+ pl->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
+ if (!pl->bridge.next_bridge)
+ return -EPROBE_DEFER;
+ }
}
pl->mst_addr = port_id - 1;
- pl->next_bridge = selected_bridge;
return 0;
}