]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/bridge: make of_drm_find_bridge() a wrapper of of_drm_find_and_get_bridge()
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 16 Dec 2025 17:58:37 +0000 (18:58 +0100)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Tue, 30 Dec 2025 09:11:32 +0000 (10:11 +0100)
of_drm_find_bridge() is identical to of_drm_find_and_get_bridge() except it
does not increment the refcount. Rewrite it as a wrapper and put the bridge
being returned so the behaviour is still the same.

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://patch.msgid.link/20251216-drm-bridge-alloc-getput-drm_of_find_bridge-v3-4-b5165fab8058@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
drivers/gpu/drm/drm_bridge.c

index f612d486cad06fe156f9f4414dc8944791b11dcc..64aa69dcf46f18cddf87fa85bbb8a26cd73d0850 100644 (file)
@@ -1529,19 +1529,17 @@ EXPORT_SYMBOL(of_drm_find_and_get_bridge);
  */
 struct drm_bridge *of_drm_find_bridge(struct device_node *np)
 {
-       struct drm_bridge *bridge;
-
-       mutex_lock(&bridge_lock);
+       struct drm_bridge *bridge = of_drm_find_and_get_bridge(np);
 
-       list_for_each_entry(bridge, &bridge_list, list) {
-               if (bridge->of_node == np) {
-                       mutex_unlock(&bridge_lock);
-                       return bridge;
-               }
-       }
+       /*
+        * We need to emulate the original semantics of
+        * of_drm_find_bridge(), which was not getting any bridge
+        * reference. Being now based on of_drm_find_and_get_bridge() which
+        * gets a reference, put it before returning.
+        */
+       drm_bridge_put(bridge);
 
-       mutex_unlock(&bridge_lock);
-       return NULL;
+       return bridge;
 }
 EXPORT_SYMBOL(of_drm_find_bridge);
 #endif