@@ -363,6 +363,9 @@ EXPORT_SYMBOL(of_drm_find_panel);
* return either the associated struct drm_panel or drm_bridge device. Either
* @panel or @bridge must not be NULL.
*
+ * If a bridge is returned in @bridge, the bridge refcount is
+ * incremented. Use drm_bridge_put() when done with the bridge.
+ *
* This function is deprecated and should not be used in new drivers. Use
* devm_drm_of_get_bridge() instead.
*
@@ -1396,6 +1396,9 @@ EXPORT_SYMBOL_GPL(drm_bridge_hpd_notify);
*
* @np: device node
*
+ * On return the bridge refcount is incremented (if the bridge is
+ * refcounted). Use drm_bridge_put() when done with the bridge.
+ *
* RETURNS:
* drm_bridge control struct on success, NULL on failure
*/
@@ -1407,6 +1410,7 @@ struct drm_bridge *of_drm_find_bridge(struct device_node *np)
list_for_each_entry(bridge, &bridge_list, list) {
if (bridge->of_node == np) {
+ drm_bridge_get(bridge);
mutex_unlock(&bridge_lock);
return bridge;
}
@@ -1427,6 +1431,9 @@ EXPORT_SYMBOL(of_drm_find_bridge);
* Given a DT node's port and endpoint number, find the connected node and
* return the associated struct drm_bridge.
*
+ * On success the returned @bridge refcount is incremented. Use
+ * drm_bridge_put() when done with the bridge.
+ *
* Returns zero if successful, or one of the standard error codes if it fails.
*/
static int of_drm_find_bridge_by_endpoint(const struct device_node *np,
@@ -172,6 +172,7 @@ static inline int drm_of_panel_bridge_remove(const struct device_node *np,
bridge = of_drm_find_bridge(remote);
drm_panel_bridge_remove(bridge);
+ drm_bridge_put(bridge);
return 0;
#else
of_drm_find_bridge() returns a pointer to a bridge, so it has to get a reference and the caller will be in charge of putting it. Callers of of_drm_find_bridge() are: 1. drm_of_panel_bridge_remove() 2. of_drm_find_bridge_by_endpoint() 3. drm_of_find_panel_or_bridge() 4. various DRM drivers Add the corresponding drm_bridge_put() call for 1 and propagate documentation to 2 and 3. Other callers (4) are to be adapted in following commits. Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> --- This patch was added in v6. --- drivers/gpu/drm/bridge/panel.c | 3 +++ drivers/gpu/drm/drm_bridge.c | 7 +++++++ include/drm/drm_of.h | 1 + 3 files changed, 11 insertions(+)