[PATCH 3/5] drm/bridge: simple-bridge: Allow acquiring the next bridge with fwnode API

Maxime Ripard mripard at kernel.org
Wed Jan 24 15:00:08 UTC 2024


On Tue, Jan 23, 2024 at 08:18:22PM +0800, Sui Jingfeng wrote:
> Hi,
> 
> 
> On 2024/1/23 09:18, Laurent Pinchart wrote:
> > On Tue, Jan 23, 2024 at 12:32:18AM +0800, Sui Jingfeng wrote:
> > > Which make it possible to use this driver on non-DT based systems,
> > > meanwhile, made no functional changes for DT based systems.
> > > 
> > > Signed-off-by: Sui Jingfeng <sui.jingfeng at linux.dev>
> > > ---
> > >   drivers/gpu/drm/bridge/simple-bridge.c | 51 ++++++++++++++++++++++----
> > >   1 file changed, 44 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
> > > index 595f672745b9..cfea5a67cc5b 100644
> > > --- a/drivers/gpu/drm/bridge/simple-bridge.c
> > > +++ b/drivers/gpu/drm/bridge/simple-bridge.c
> > > @@ -184,6 +184,39 @@ static const void *simple_bridge_get_match_data(const struct device *dev)
> > >   	return NULL;
> > >   }
> > > +static int simple_bridge_get_next_bridge_by_fwnode(struct device *dev,
> > > +						   struct drm_bridge **next_bridge)
> > > +{
> > > +	struct drm_bridge *bridge;
> > > +	struct fwnode_handle *ep;
> > > +	struct fwnode_handle *remote;
> > > +
> > > +	ep = fwnode_graph_get_endpoint_by_id(dev->fwnode, 1, 0, 0);
> > > +	if (!ep) {
> > > +		dev_err(dev, "The endpoint is unconnected\n");
> > > +		return -EINVAL;
> > > +	}
> > > +
> > > +	remote = fwnode_graph_get_remote_port_parent(ep);
> > > +	fwnode_handle_put(ep);
> > > +	if (!remote) {
> > > +		dev_err(dev, "No valid remote node\n");
> > > +		return -ENODEV;
> > > +	}
> > > +
> > > +	bridge = drm_bridge_find_by_fwnode(remote);
> > > +	fwnode_handle_put(remote);
> > > +
> > > +	if (!bridge) {
> > > +		dev_warn(dev, "Next bridge not found, deferring probe\n");
> > > +		return -EPROBE_DEFER;
> > > +	}
> > > +
> > > +	*next_bridge = bridge;
> > > +
> > > +	return 0;
> > > +}
> > > +
> > Hmmmm yes, this convinces me further that we should switch to fwnode,
> > not implement fwnode and OF side-by-side.
> > 
> 
> OK, I'm agree with you.
> 
> 
> But this means that I have to make the drm_bridge_find_by_fwnode() function works
> on both DT systems and non-DT systems. This is also means that we will no longer
> need to call of_drm_find_bridge() function anymore. This will eventually lead to
> completely remove of_drm_find_bridge()?
> 
> 
> As far as I can see, if I follow you suggestion, drm/bridge subsystem will
> encountering a *big* refactor. My 'side-by-side' approach allows co-exist.
> It is not really meant to purge OF. I feel it is a little bit of aggressive.
> 
> hello Maxime, are you watching this? what do you think?

It's indeed going to be a pretty big refactoring, but I agree with
Laurent that we don't want to maintain both side by side.

Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20240124/298290a8/attachment.sig>


More information about the dri-devel mailing list