[PATCH RFC 13/19] drm/bridge: Add the drm_bridge_chain_get_prev_bridge() helper
Boris Brezillon
boris.brezillon at collabora.com
Thu Aug 22 08:04:25 UTC 2019
On Thu, 22 Aug 2019 03:17:32 +0300
Laurent Pinchart <laurent.pinchart at ideasonboard.com> wrote:
> 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" ?
Yes, sorry about that, I meant "if @bridge is the first", indeed.
>
> > + */
> > +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 ?
Maybe not.
> 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 ?
I think this checks was done when bridge iteration was based on
recursivity, which is no longer the case.
>
> > + 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);
>
More information about the dri-devel
mailing list