[PATCH 4/9] drm/omapdrm: use drm_bridge_chain_get_last_bridge()

Maxime Ripard mripard at kernel.org
Fri Jul 25 07:15:23 PDT 2025


On Mon, Jul 14, 2025 at 12:32:40PM +0200, Luca Ceresoli wrote:
> Hi Maxime,
> 
> On Thu, 10 Jul 2025 09:13:46 +0200
> Maxime Ripard <mripard at kernel.org> wrote:
> 
> > On Wed, Jul 09, 2025 at 06:48:03PM +0200, Luca Ceresoli wrote:
> > > Use drm_bridge_chain_get_last_bridge() instead of open coding a loop with
> > > two invocations of drm_bridge_get_next_bridge() per iteration.
> > > 
> > > Besides being cleaner and more efficient, this change is necessary in
> > > preparation for drm_bridge_get_next_bridge() to get a reference to the
> > > returned bridge.
> > > 
> > > Signed-off-by: Luca Ceresoli <luca.ceresoli at bootlin.com>
> > > ---
> > >  drivers/gpu/drm/omapdrm/omap_drv.c | 8 ++++----
> > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> > > index 054b71dba6a75b8c42198c4b102a093f43a675a2..3bbcec01428a6f290afdfa40ef6f79629539a584 100644
> > > --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> > > +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> > > @@ -378,12 +378,12 @@ static int omap_display_id(struct omap_dss_device *output)
> > >  	struct device_node *node = NULL;
> > >  
> > >  	if (output->bridge) {
> > > -		struct drm_bridge *bridge = output->bridge;
> > > -
> > > -		while (drm_bridge_get_next_bridge(bridge))
> > > -			bridge = drm_bridge_get_next_bridge(bridge);
> > > +		struct drm_bridge *bridge =
> > > +			drm_bridge_chain_get_last_bridge(output->bridge->encoder);
> > >  
> > >  		node = bridge->of_node;
> > > +
> > > +		drm_bridge_put(bridge);  
> > 
> > Any reason you're not using __free(drm_bridge_put) here?
> 
> Just because the code is simple enough that an explicit
> drm_bridge_put() is clearly sufficient.
> 
> Do you think __free() should be used even in such trivial cases?

It's a matter of opinion at this point :)

It' makes it a bit easier and consistent so that's why I raised it, but
if you feel like it's too much, that's fine by me as well.

Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20250725/d500b988/attachment.sig>


More information about the linux-arm-kernel mailing list