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

drm/bridge: add drm_for_each_bridge_in_chain_from()

Add variant of drm_for_each_bridge_in_chain_scoped() that iterates on the
encoder bridge from a given bridge until the end of the chain.

Reviewed-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20250808-drm-bridge-alloc-getput-for_each_bridge-v2-8-edb6ee81edf1@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

+19
+19
include/drm/drm_bridge.h
··· 1471 1471 bridge; \ 1472 1472 bridge = drm_bridge_get_next_bridge_and_put(bridge)) 1473 1473 1474 + /** 1475 + * drm_for_each_bridge_in_chain_from - iterate over all bridges starting 1476 + * from the given bridge 1477 + * @first_bridge: the bridge to start from 1478 + * @bridge: a bridge pointer updated to point to the current bridge at each 1479 + * iteration 1480 + * 1481 + * Iterate over all bridges in the encoder chain starting from 1482 + * @first_bridge, included. 1483 + * 1484 + * Automatically gets/puts the bridge reference while iterating, and puts 1485 + * the reference even if returning or breaking in the middle of the loop. 1486 + */ 1487 + #define drm_for_each_bridge_in_chain_from(first_bridge, bridge) \ 1488 + for (struct drm_bridge *bridge __free(drm_bridge_put) = \ 1489 + drm_bridge_get(first_bridge); \ 1490 + bridge; \ 1491 + bridge = drm_bridge_get_next_bridge_and_put(bridge)) 1492 + 1474 1493 enum drm_mode_status 1475 1494 drm_bridge_chain_mode_valid(struct drm_bridge *bridge, 1476 1495 const struct drm_display_info *info,