Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1574992

Re: [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge

From Rob Herring <robh@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge
Date 2017-02-06 18:00 +0100
Message-ID <t7UNZ-7sP-27@gated-at.bofh.it> (permalink)
References <t6ZmF-32o-3@gated-at.bofh.it> <t6ZmG-32o-9@gated-at.bofh.it> <t7P1U-3Pt-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Feb 06, 2017 at 11:42:48AM +0100, Philipp Zabel wrote:
> On Fri, 2017-02-03 at 21:36 -0600, Rob Herring wrote:
> > Many drivers have a common pattern of searching the OF graph for either an
> > attached panel or bridge and then finding the DRM struct for the panel
> > or bridge. Also, most drivers need to handle deferred probing when the
> > DRM device is not yet instantiated. Create a common function,
> > drm_of_find_panel_or_bridge, to find the connected node and the
> > associated DRM panel or bridge device.

[...]

> > +int drm_of_find_panel_or_bridge(const struct device_node *np,
> > +				int port, int endpoint,
> > +				struct drm_panel **panel,
> > +				struct drm_bridge **bridge)
> > +{
> > +	int ret = -ENODEV;
> 
> This is only returned if !panel && !bridge. I'd consider this invalid
> usage of this function, so maybe use -EINVAL?

Yes.

> > +	struct device_node *remote;
> > +
> > +	remote = of_graph_get_remote_node(np, port, endpoint);
> > +	if (!remote)
> > +		return -ENODEV;
> > +
> > +	if (bridge)
> > +		*bridge = NULL;
> 
> I would move this ^ ...
> 
> > +	if (panel) {
> > +		*panel = of_drm_find_panel(remote);
> > +		if (*panel) {
> 
> ... here.

Okay.

> > +			ret = 0;
> > +			goto out_put;
> > +		}
> > +		ret = -EPROBE_DEFER;
> > +	}
> > +
> > +	if (bridge) {
> > +		*bridge = of_drm_find_bridge(remote);
> > +		if (*bridge)
> > +			ret = 0;
> > +		else
> > +			ret = -EPROBE_DEFER;
> > +	}
> > +out_put:
> > +	of_node_put(remote);
> > +	return ret;
> > +}

I've ended up re-writing things a bit getting rid of the goto and the 
result looks like this:

int drm_of_find_panel_or_bridge(const struct device_node *np,
				int port, int endpoint,
				struct drm_panel **panel,
				struct drm_bridge **bridge)
{
	int ret = -EPROBE_DEFER;
	struct device_node *remote;

	if (!panel && !bridge)
		return -EINVAL;

	remote = of_graph_get_remote_node(np, port, endpoint);
	if (!remote)
		return -ENODEV;

	if (panel) {
		*panel = of_drm_find_panel(remote);
		if (*panel) {
			if (bridge)
				*bridge = NULL;
			ret = 0;
		}
	}

	/* No panel found yet, check for a bridge next. */
	if (ret && bridge) {
		*bridge = of_drm_find_bridge(remote);
		if (*bridge)
			ret = 0;
	}

	of_node_put(remote);
	return ret;
}

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] DRM OF graph clean-up Rob Herring <robh@kernel.org> - 2017-02-04 04:40 +0100
  [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge Rob Herring <robh@kernel.org> - 2017-02-04 04:40 +0100
    Re: [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge Liviu Dudau <liviu.dudau@arm.com> - 2017-02-06 11:20 +0100
      Re: [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge Rob Herring <robh@kernel.org> - 2017-02-06 17:30 +0100
    Re: [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge Philipp Zabel <p.zabel@pengutronix.de> - 2017-02-06 11:50 +0100
      Re: [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge Rob Herring <robh@kernel.org> - 2017-02-06 18:00 +0100
        Re: [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge Philipp Zabel <p.zabel@pengutronix.de> - 2017-02-06 18:50 +0100
    Re: [PATCH 2/5] drm: of: introduce drm_of_find_panel_or_bridge Frank Rowand <frowand.list@gmail.com> - 2017-02-10 21:00 +0100
  [PATCH 1/5] of: introduce of_graph_get_remote_node Rob Herring <robh@kernel.org> - 2017-02-04 04:40 +0100
    Re: [PATCH 1/5] of: introduce of_graph_get_remote_node Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> - 2017-02-04 17:20 +0100
    Re: [PATCH 1/5] of: introduce of_graph_get_remote_node Daniel Vetter <daniel@ffwll.ch> - 2017-02-06 10:00 +0100
      Re: [PATCH 1/5] of: introduce of_graph_get_remote_node Rob Herring <robh@kernel.org> - 2017-02-06 14:50 +0100
    Re: [PATCH 1/5] of: introduce of_graph_get_remote_node Philipp Zabel <p.zabel@pengutronix.de> - 2017-02-06 11:40 +0100
      Re: [PATCH 1/5] of: introduce of_graph_get_remote_node Rob Herring <robh@kernel.org> - 2017-02-06 15:00 +0100
        Re: [PATCH 1/5] of: introduce of_graph_get_remote_node Philipp Zabel <p.zabel@pengutronix.de> - 2017-02-06 15:10 +0100
  [PATCH 5/5] drm: omap: use common OF graph helpers Rob Herring <robh@kernel.org> - 2017-02-04 04:40 +0100
  Re: [PATCH 0/5] DRM OF graph clean-up Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-02-04 11:50 +0100

csiph-web