[v2,15/21] drm/bridge: Add the drm_bridge_chain_get_prev_bridge() helper
diff mbox series

Message ID 20190826152649.13820-16-boris.brezillon@collabora.com
State New
Headers show
Series
  • drm: Add support for bus-format negotiation
Related show

Commit Message

Boris Brezillon Aug. 26, 2019, 3:26 p.m. UTC
Will be useful for bridge drivers that want to do bus format
negotiation with their neighbours.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
Changes in v2:
* Fix the kerneldoc
* Drop the !bridge || !bridge->encoder check
---
 drivers/gpu/drm/drm_bridge.c | 17 +++++++++++++++++
 include/drm/drm_bridge.h     |  2 ++
 2 files changed, 19 insertions(+)

Comments

Neil Armstrong Aug. 27, 2019, 7:26 a.m. UTC | #1
On 26/08/2019 17:26, Boris Brezillon wrote:
> Will be useful for bridge drivers that want to do bus format
> negotiation with their neighbours.

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>

> 
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
> Changes in v2:
> * Fix the kerneldoc
> * Drop the !bridge || !bridge->encoder check
> ---
>  drivers/gpu/drm/drm_bridge.c | 17 +++++++++++++++++
>  include/drm/drm_bridge.h     |  2 ++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 7f7e0ea5b06c..9c74b285da9d 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -238,6 +238,23 @@ drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge)
>  }
>  EXPORT_SYMBOL(drm_bridge_chain_get_next_bridge);
>  
> +/**
> + * drm_bridge_chain_get_prev_bridge() - Get the previous bridge in the chain
> + * @bridge: bridge object
> + *
> + * RETURNS:
> + * the previous bridge in the chain, or NULL if @bridge is the last.
> + */
> +struct drm_bridge *
> +drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge)
> +{
> +	if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain))
> +		return NULL;
> +
> +	return list_prev_entry(bridge, chain_node);
> +}
> +EXPORT_SYMBOL(drm_bridge_chain_get_prev_bridge);
> +
>  /**
>   * DOC: bridge callbacks
>   *
> diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
> index 7fdce6dc5f26..95dc58c3a4e8 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -521,6 +521,8 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
>  
>  struct drm_bridge *
>  drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge);
> +struct drm_bridge *
> +drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge);
>  bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
>  				 const struct drm_display_mode *mode,
>  				 struct drm_display_mode *adjusted_mode);
>

Patch
diff mbox series

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 7f7e0ea5b06c..9c74b285da9d 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -238,6 +238,23 @@  drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge)
 }
 EXPORT_SYMBOL(drm_bridge_chain_get_next_bridge);
 
+/**
+ * drm_bridge_chain_get_prev_bridge() - Get the previous bridge in the chain
+ * @bridge: bridge object
+ *
+ * RETURNS:
+ * the previous bridge in the chain, or NULL if @bridge is the last.
+ */
+struct drm_bridge *
+drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge)
+{
+	if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain))
+		return NULL;
+
+	return list_prev_entry(bridge, chain_node);
+}
+EXPORT_SYMBOL(drm_bridge_chain_get_prev_bridge);
+
 /**
  * DOC: bridge callbacks
  *
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 7fdce6dc5f26..95dc58c3a4e8 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -521,6 +521,8 @@  int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
 
 struct drm_bridge *
 drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge);
+struct drm_bridge *
+drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge);
 bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
 				 const struct drm_display_mode *mode,
 				 struct drm_display_mode *adjusted_mode);