[PATCH v2 01/13] drm/sun4i: backend: Simplify the get_id logic
Maxime Ripard
maxime.ripard at bootlin.com
Fri Mar 15 08:38:09 UTC 2019
On Fri, Mar 15, 2019 at 10:43:48AM +0800, Chen-Yu Tsai wrote:
> On Fri, Mar 15, 2019 at 4:16 AM Maxime Ripard <maxime.ripard at bootlin.com> wrote:
> >
> > Using the new helpers introduced since we wrote that code, we can simplify
> > the code to retrieve the backend ID significantly.
> >
> > The new code will also allow us to deal nicely with endpoints that don't
> > have a reg property, as expected in the case where there's a single
> > endpoint for a given port.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard at bootlin.com>
> > ---
> > drivers/gpu/drm/sun4i/sun4i_backend.c | 34 +++++++++-------------------
> > 1 file changed, 11 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
> > index 4c0d51f73237..02ef8e455db8 100644
> > --- a/drivers/gpu/drm/sun4i/sun4i_backend.c
> > +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
> > @@ -720,33 +720,21 @@ static int sun4i_backend_free_sat(struct device *dev) {
> > */
> > static int sun4i_backend_of_get_id(struct device_node *node)
> > {
> > - struct device_node *port, *ep;
> > - int ret = -EINVAL;
> > + struct device_node *ep, *remote;
> > + struct of_endpoint of_ep;
> >
> > - /* input is port 0 */
> > - port = of_graph_get_port_by_id(node, 0);
> > - if (!port)
> > + /* Input port is 0, and we want the first endpoint. */
> > + ep = of_graph_get_endpoint_by_regs(node, 0, -1);
> > + if (!ep)
> > return -EINVAL;
> >
> > - /* try finding an upstream endpoint */
> > - for_each_available_child_of_node(port, ep) {
> > - struct device_node *remote;
> > - u32 reg;
> > -
> > - remote = of_graph_get_remote_endpoint(ep);
> > - if (!remote)
> > - continue;
> > -
> > - ret = of_property_read_u32(remote, "reg", ®);
> > - if (ret)
> > - continue;
> > -
> > - ret = reg;
> > - }
> > -
> > - of_node_put(port);
> > + remote = of_graph_get_remote_endpoint(ep);
>
> I believe you also need to call of_node_put for ep?
Ah, right. It wasn't mentionned in the doc, but you definitely need
it. I'll send a patch for that.
> Otherwise,
>
> Reviewed-by: Chen-Yu Tsai <wens at csie.org>
Thanks!
I've applied this on and the next and added the of_node_put in the
process.
Maxime
--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- 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/20190315/6e8a35ae/attachment.sig>
More information about the dri-devel
mailing list