[PATCH RFC 13/19] drm/bridge: Add the drm_bridge_chain_get_prev_bridge() helper
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu Aug 22 00:17:32 UTC 2019
Hi Boris,
Thank you for the patch.
On Thu, Aug 08, 2019 at 05:11:44PM +0200, Boris Brezillon wrote:
> Will be useful for bridge drivers that want to do bus format
> negotiation with their neighbours.
>
> Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
> ---
> drivers/gpu/drm/drm_bridge.c | 19 +++++++++++++++++++
> include/drm/drm_bridge.h | 2 ++
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index dcad661daa74..9efb27087e70 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -271,6 +271,25 @@ 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 there's @bridge is the
> + * last.
Did you mean "if the @bridge is the first" ?
> + */
> +struct drm_bridge *
> +drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge)
> +{
> + if (!bridge || !bridge->encoder ||
Do we really need to protect against !bridge and !bridge->encoder, can
that happen ? Especially !bridge, are there use cases for potentially
calling this function (and the other list traversal helpers in your
previous patches) with a NULL bridge ?
> + list_is_first(&bridge->encoder->bridge_chain, &bridge->chain_node))
> + 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 5d8fe3709bde..2f69adb7b0f3 100644
> --- a/include/drm/drm_bridge.h
> +++ b/include/drm/drm_bridge.h
> @@ -485,6 +485,8 @@ struct drm_bridge *
> drm_bridge_chain_get_last_bridge(struct drm_encoder *encoder);
> 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_encoder *encoder,
> const struct drm_display_mode *mode,
> struct drm_display_mode *adjusted_mode);
--
Regards,
Laurent Pinchart
More information about the dri-devel
mailing list