drm/bridge: deprecate of_drm_find_bridge()

of_drm_find_bridge() does not increment the returned bridge
refcount. of_drm_find_and_get_bridge() is to be used as a replacement.

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-2-b5165fab8058@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
This commit is contained in:
Luca Ceresoli 2025-12-16 18:58:35 +01:00
parent 293a8fd772
commit 9da0e06abd

View File

@ -361,7 +361,7 @@ EXPORT_SYMBOL(__devm_drm_bridge_alloc);
* @bridge: bridge control structure * @bridge: bridge control structure
* *
* Add the given bridge to the global list of bridges, where they can be * Add the given bridge to the global list of bridges, where they can be
* found by users via of_drm_find_bridge(). * found by users via of_drm_find_and_get_bridge().
* *
* The bridge to be added must have been allocated by * The bridge to be added must have been allocated by
* devm_drm_bridge_alloc(). * devm_drm_bridge_alloc().
@ -422,9 +422,9 @@ EXPORT_SYMBOL(devm_drm_bridge_add);
* @bridge: bridge control structure * @bridge: bridge control structure
* *
* Remove the given bridge from the global list of registered bridges, so * Remove the given bridge from the global list of registered bridges, so
* it won't be found by users via of_drm_find_bridge(), and add it to the * it won't be found by users via of_drm_find_and_get_bridge(), and add it
* lingering bridge list, to keep track of it until its allocated memory is * to the lingering bridge list, to keep track of it until its allocated
* eventually freed. * memory is eventually freed.
*/ */
void drm_bridge_remove(struct drm_bridge *bridge) void drm_bridge_remove(struct drm_bridge *bridge)
{ {
@ -1510,6 +1510,20 @@ EXPORT_SYMBOL(of_drm_find_and_get_bridge);
* *
* @np: device node * @np: device node
* *
* This function is deprecated. Convert to of_drm_find_and_get_bridge()
* instead for proper refcounting.
*
* The bridge returned by this function is not refcounted. This is
* dangerous because the bridge might be deallocated even before the caller
* has a chance to use it. To use this function you have to do one of:
* - get a reference with drm_bridge_get() as soon as possible to
* minimize the race window, and then drm_bridge_put() when no longer
* using the pointer
* - not call drm_bridge_get() or drm_bridge_put() at all, which used to
* be the correct practice before dynamic bridge lifetime was introduced
* - again, convert to of_drm_find_and_get_bridge(), which is the only safe
* thing to do
*
* RETURNS: * RETURNS:
* drm_bridge control struct on success, NULL on failure * drm_bridge control struct on success, NULL on failure
*/ */