From: Luca Ceresoli Date: Fri, 1 Aug 2025 17:05:27 +0000 (+0200) Subject: drm/bridge: add drm_bridge_is_last() X-Git-Tag: v6.18-rc1~134^2~16^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e4cedfd4f0fc839bb3c783d7e827e9755e1af5cf;p=thirdparty%2Fkernel%2Flinux.git drm/bridge: add drm_bridge_is_last() Some code needing to know whether a bridge is the last in a chain currently call drm_bridge_get_next_bridge(). However drm_bridge_get_next_bridge() will soon increment the refcount of the returned bridge, which would make such code more annoying to write. In preparation for drm_bridge_get_next_bridge() to increment the refcount, as well as to simplify such code, introduce a simple bool function to tell whether a bridge is the last in the chain. Reviewed-by: Maxime Ripard Link: https://lore.kernel.org/r/20250801-drm-bridge-alloc-getput-drm_bridge_get_next_bridge-v2-5-888912b0be13@bootlin.com Signed-off-by: Luca Ceresoli --- diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 788517ab00d3c..76e05930f50e0 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1321,6 +1321,11 @@ static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np) } #endif +static inline bool drm_bridge_is_last(struct drm_bridge *bridge) +{ + return list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain); +} + /** * drm_bridge_get_current_state() - Get the current bridge state * @bridge: bridge object