[PATCH v2 04/26] drm/bridge: make of_drm_find_bridge() a wrapper of of_drm_get_bridge()
Luca Ceresoli
luca.ceresoli at bootlin.com
Fri Nov 28 08:50:14 PST 2025
of_drm_find_bridge() is identical to of_drm_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.
Signed-off-by: Luca Ceresoli <luca.ceresoli at bootlin.com>
---
Changed in v2:
- Added comment to document why we put the reference
---
drivers/gpu/drm/drm_bridge.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 21a84715d221..9b7e3f859973 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1467,19 +1467,17 @@ EXPORT_SYMBOL(of_drm_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_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_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
--
2.51.1
More information about the linux-amlogic
mailing list