]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm: zynqmp_dp: switch to of_drm_get_bridge_by_endpoint()
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Mon, 11 May 2026 16:40:14 +0000 (18:40 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 19 May 2026 08:57:26 +0000 (10:57 +0200)
This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the
@panel parameter, thus using a reduced feature set of that function.
Replace this call with the simpler of_drm_get_bridge_by_endpoint().

Since of_drm_get_bridge_by_endpoint() increases the refcount of the
returned bridge, ensure it is put on removal. To achieve this, instead of
adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge
pointer which is automatically put when the bridge is eventually freed.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patch.msgid.link/20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-10-f61c9e498b3f@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/xlnx/zynqmp_dp.c

index 05bd31fe675bc8cd64ac7d3764cfb663e2bc67fa..7fb11b0a44f0cacad79ab684b594bc05fcc22d13 100644 (file)
@@ -353,7 +353,6 @@ struct zynqmp_dp_train_set_priv {
  * @lock: Mutex protecting this struct and register access (but not AUX)
  * @irq: irq
  * @bridge: DRM bridge for the DP encoder
- * @next_bridge: The downstream bridge
  * @test: Configuration for test mode
  * @config: IP core configuration from DTS
  * @aux: aux channel
@@ -385,7 +384,6 @@ struct zynqmp_dp {
        struct completion aux_done;
        struct mutex lock;
 
-       struct drm_bridge *next_bridge;
        struct device *dev;
        struct zynqmp_dpsub *dpsub;
        void __iomem *iomem;
@@ -1494,8 +1492,8 @@ static int zynqmp_dp_bridge_attach(struct drm_bridge *bridge,
                return ret;
        }
 
-       if (dp->next_bridge) {
-               ret = drm_bridge_attach(encoder, dp->next_bridge,
+       if (dp->bridge.next_bridge) {
+               ret = drm_bridge_attach(encoder, dp->bridge.next_bridge,
                                        bridge, flags);
                if (ret < 0)
                        goto error;
@@ -2461,10 +2459,15 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
         * Acquire the next bridge in the chain. Ignore errors caused by port@5
         * not being connected for backward-compatibility with older DTs.
         */
-       ret = drm_of_find_panel_or_bridge(dp->dev->of_node, 5, 0, NULL,
-                                         &dp->next_bridge);
-       if (ret < 0 && ret != -ENODEV)
-               goto err_reset;
+       dp->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dp->dev->of_node, 5, 0);
+       if (IS_ERR(dp->bridge.next_bridge)) {
+               if (PTR_ERR(dp->bridge.next_bridge) != -ENODEV) {
+                       ret = PTR_ERR(dp->bridge.next_bridge);
+                       goto err_reset;
+               }
+
+               dp->bridge.next_bridge = NULL;
+       }
 
        /* Initialize the hardware. */
        dp->config.misc0 &= ~ZYNQMP_DP_MAIN_STREAM_MISC0_SYNC_LOCK;