Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+30
+25
drivers/gpu/drm/drm_bridge.c
··· 1480 1480 1481 1481 #ifdef CONFIG_OF 1482 1482 /** 1483 + * of_drm_find_and_get_bridge - find the bridge corresponding to the device 1484 + * node in the global bridge list 1485 + * @np: device node 1486 + * 1487 + * The refcount of the returned bridge is incremented. Use drm_bridge_put() 1488 + * when done with it. 1489 + * 1490 + * RETURNS: 1491 + * drm_bridge control struct on success, NULL on failure 1492 + */ 1493 + struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np) 1494 + { 1495 + struct drm_bridge *bridge; 1496 + 1497 + scoped_guard(mutex, &bridge_lock) { 1498 + list_for_each_entry(bridge, &bridge_list, list) 1499 + if (bridge->of_node == np) 1500 + return drm_bridge_get(bridge); 1501 + } 1502 + 1503 + return NULL; 1504 + } 1505 + EXPORT_SYMBOL(of_drm_find_and_get_bridge); 1506 + 1507 + /** 1483 1508 * of_drm_find_bridge - find the bridge corresponding to the device node in 1484 1509 * the global bridge list 1485 1510 *
+5
include/drm/drm_bridge.h
··· 1326 1326 enum drm_bridge_attach_flags flags); 1327 1327 1328 1328 #ifdef CONFIG_OF 1329 + struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np); 1329 1330 struct drm_bridge *of_drm_find_bridge(struct device_node *np); 1330 1331 #else 1332 + static inline struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np) 1333 + { 1334 + return NULL; 1335 + } 1331 1336 static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np) 1332 1337 { 1333 1338 return NULL;