[PATCH 5/9] drm/bridge: add drm_bridge_is_last()

Luca Ceresoli posted 9 patches 2 months, 4 weeks ago
[PATCH 5/9] drm/bridge: add drm_bridge_is_last()
Posted by Luca Ceresoli 2 months, 4 weeks ago
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.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
 include/drm/drm_bridge.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 9a7e9dd8cbfa54eedb82981032a25009e845a037..c2a7a7d2dfc420e9dcf7ea4c093ce1f1b939c820 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -1264,6 +1264,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

-- 
2.50.0
Re: [PATCH 5/9] drm/bridge: add drm_bridge_is_last()
Posted by Maxime Ripard 2 months, 4 weeks ago
On Wed, 9 Jul 2025 18:48:04 +0200, Luca Ceresoli wrote:
> 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.
> 
> 
> [ ... ]

Reviewed-by: Maxime Ripard <mripard@kernel.org>

Thanks!
Maxime