summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorLuca Ceresoli <luca.ceresoli@bootlin.com>2025-12-16 18:58:34 +0100
committerLuca Ceresoli <luca.ceresoli@bootlin.com>2025-12-30 10:11:32 +0100
commit293a8fd7721a90987d9bf149feab60e756dac269 (patch)
tree14c064a35c49446715a1225a20f9ee7505282067 /drivers/gpu
parent130343ee6bca9895c47d314467db7dd3dcc8bc35 (diff)
downloadlinux-next-293a8fd7721a90987d9bf149feab60e756dac269.tar.gz
linux-next-293a8fd7721a90987d9bf149feab60e756dac269.zip
drm/bridge: add of_drm_find_and_get_bridge()
of_drm_find_bridge() does not increment the refcount for the returned bridge, but that is required now. However converting it and all its users is not realistically doable at once given the large amount of (direct and indirect) callers and the complexity of some. Solve this issue by creating a new of_drm_find_and_get_bridge() function that is identical to of_drm_find_bridge() except also it takes a reference. Then of_drm_find_bridge() will be deprecated to be eventually removed. Suggested-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/dri-devel/20250319-stylish-lime-mongoose-0a18ad@houat/ Reviewed-by: Maxime Ripard <mripard@kernel.org> Link: https://patch.msgid.link/20251216-drm-bridge-alloc-getput-drm_of_find_bridge-v3-1-b5165fab8058@bootlin.com Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_bridge.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index db40c26d1cb3..0dbc8b59c3be 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -1480,6 +1480,31 @@ EXPORT_SYMBOL_GPL(drm_bridge_hpd_notify);
#ifdef CONFIG_OF
/**
+ * of_drm_find_and_get_bridge - find the bridge corresponding to the device
+ * node in the global bridge list
+ * @np: device node
+ *
+ * The refcount of the returned bridge is incremented. Use drm_bridge_put()
+ * when done with it.
+ *
+ * RETURNS:
+ * drm_bridge control struct on success, NULL on failure
+ */
+struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np)
+{
+ struct drm_bridge *bridge;
+
+ scoped_guard(mutex, &bridge_lock) {
+ list_for_each_entry(bridge, &bridge_list, list)
+ if (bridge->of_node == np)
+ return drm_bridge_get(bridge);
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL(of_drm_find_and_get_bridge);
+
+/**
* of_drm_find_bridge - find the bridge corresponding to the device node in
* the global bridge list
*