From: Maxime Ripard Subject: Re: [PATCH v2 01/13] drm/sun4i: backend: Simplify the get_id logic Date: Fri, 15 Mar 2019 09:38:09 +0100 Message-ID: <20190315083809.xibciwfpebru5vix@flea> References: <1a9bf911b0a40475da8025859032514131d5397b.1552594551.git-series.maxime.ripard@bootlin.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1331093830==" Return-path: Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by gabe.freedesktop.org (Postfix) with ESMTPS id 70BC46E336 for ; Fri, 15 Mar 2019 08:38:14 +0000 (UTC) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Chen-Yu Tsai Cc: Sean Paul , linux-arm-kernel , dri-devel List-Id: dri-devel@lists.freedesktop.org --===============1331093830== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="fw6froabzxkpk2gu" Content-Disposition: inline --fw6froabzxkpk2gu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 = wrote: > > > > Using the new helpers introduced since we wrote that code, we can simpl= ify > > 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 > > --- > > 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/su= n4i/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 =3D -EINVAL; > > + struct device_node *ep, *remote; > > + struct of_endpoint of_ep; > > > > - /* input is port 0 */ > > - port =3D of_graph_get_port_by_id(node, 0); > > - if (!port) > > + /* Input port is 0, and we want the first endpoint. */ > > + ep =3D 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 =3D of_graph_get_remote_endpoint(ep); > > - if (!remote) > > - continue; > > - > > - ret =3D of_property_read_u32(remote, "reg", ®); > > - if (ret) > > - continue; > > - > > - ret =3D reg; > > - } > > - > > - of_node_put(port); > > + remote =3D of_graph_get_remote_endpoint(ep); >=20 > 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, >=20 > Reviewed-by: Chen-Yu Tsai Thanks! I've applied this on and the next and added the of_node_put in the process. Maxime --=20 Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --fw6froabzxkpk2gu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXItkcQAKCRDj7w1vZxhR xY7nAQDFvx/3Uv6gGOM9blyjQtBCizVaKRDj86pZ173LLIfptAD/XAoIeMeAgZOs NKICLNzETTTytrzQjN8CJ0NzwY4OQA4= =/r7J -----END PGP SIGNATURE----- --fw6froabzxkpk2gu-- --===============1331093830== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVs --===============1331093830==--