From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH libdrm v3 3/5] xf86drm: Add platform and host1x bus support Date: Thu, 19 Jan 2017 11:25:51 +0100 Message-ID: <20170119102551.GC30182@ulmo.ba.sec> References: <20170118090209.13819-1-thierry.reding@gmail.com> <20170118090209.13819-4-thierry.reding@gmail.com> <587F8304.90105@bfs.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0300487348==" Return-path: Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF8EC6E9BA for ; Thu, 19 Jan 2017 10:25:54 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id d140so10913914wmd.2 for ; Thu, 19 Jan 2017 02:25:54 -0800 (PST) In-Reply-To: <587F8304.90105@bfs.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: walter harms Cc: xorg-devel@lists.x.org, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============0300487348== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="t0UkRYy7tHLRMCai" Content-Disposition: inline --t0UkRYy7tHLRMCai Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Adding back dri-devel@lists.freedesktop.org On Wed, Jan 18, 2017 at 04:00:20PM +0100, walter harms wrote: > Am 18.01.2017 10:02, schrieb Thierry Reding: [...] > > diff --git a/xf86drm.c b/xf86drm.c [...] > > @@ -3187,11 +3199,55 @@ static int drmParsePciDeviceInfo(int maj, int m= in, > > #endif > > } > > =20 > > +static void drmFreePlatformDevice(drmDevicePtr device) > > +{ > > + if (device->deviceinfo.platform) { >=20 > to save 2 indent level and improve readability : >=20 > if (! device->deviceinfo.platform || > ! device->deviceinfo.platform->compatible) > return; >=20 > > + if (device->deviceinfo.platform->compatible) { > > + char **compatible =3D device->deviceinfo.platform->compati= ble; > > + > > + while (*compatible) { > > + free(*compatible); > > + compatible++; > > + } > > + > > + free(device->deviceinfo.platform->compatible); > > + } > > + } I chose the above style because I thought readability wasn't impacted and it has the advantage of making the code more easily extensible should we ever need to add code to it. > > +static int drmProcessHost1xDevice(drmDevicePtr *device, > > + const char *node, int node_type, > > + int maj, int min, bool fetch_devicei= nfo, > > + uint32_t flags) > > +{ > > + drmDevicePtr dev; > > + char *ptr; > > + int ret; > > + > > + dev =3D drmDeviceAlloc(node_type, node, sizeof(drmHost1xBusInfo), > > + sizeof(drmHost1xDeviceInfo), &ptr); > > + if (!dev) > > + return -ENOMEM; > > + > > + dev->bustype =3D DRM_BUS_HOST1X; > > + > > + dev->businfo.host1x =3D (drmHost1xBusInfoPtr)ptr; > > + > > + ret =3D drmParseHost1xBusInfo(maj, min, dev->businfo.host1x); > > + if (ret < 0) > > + goto free_device; > > + > > + if (fetch_deviceinfo) { > > + ptr +=3D sizeof(drmHost1xBusInfo); > > + dev->deviceinfo.host1x =3D (drmHost1xDeviceInfoPtr)ptr; > > + > > + ret =3D drmParseHost1xDeviceInfo(maj, min, dev->deviceinfo.hos= t1x); > > + if (ret < 0) > > + goto free_device; > > + } > > + > > + *device =3D dev; > > + >=20 > do you assume that fetch_deviceinfo may change dev ? No, why? Thierry --t0UkRYy7tHLRMCai Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAliAlC4ACgkQ3SOs138+ s6GMHA//SUBRiIVMeeJ0lmTsiTxcw1VCzhLg+Qf8+ItsA2uxoz9Uc5kVepWkpGnC L0zQ4oe1jLGfhknbmQEUKcGltVxcHlTyiCQKtIhBs5/MAHIgiJtURVS4rV7ZDgw/ rncjgYVGR7WQYM355K+p4bgK8Iq0x9VUoTeXsS0QvGEaWn0XrZRuWNtABDS9Qm6H PvrY6QY/yNWiPc3MepnNqAer9VX/Gs0YmvizSHYxx5DCZzCUsK5gEN4xHl4smJ0a SVN9Ch3cpvhdMHTppw2TnIkjx8XIs817IRGvdmCyMYrd/4DAoop2d9zcGr4D11jP en1wPrfvETRrjR/kehDJ/z8OkYnOlcOJwrswwxslHpvc1dLt1HXthcdW6hWHvQ5v nzMLO5WxPbTqqBzQwh9jlcrL0AwrjH3sa/8uyeRFgHPFOMWiwpv7nKPwpG8Vql8m edm+y4AjdFA5IG6p0XeyqzNNZ3odBm+aJgFju8IyfZPE9hK/hTdRTXd4hem3GP9q h5C7OLiNnNj16iCPd3GtR04z61fRBP1C+hZVEK8N7LKEgCa4gjkbryw3XXzadvSh RMmX6unEkDXR0JfavoNJjbvfGs+4H41i84jsuNPAm39BaZuMRZGxpcdbRzNF1+Yv rBapQ7sjcgc5l0SS2/JOPLwpVIUEKHdGBTJ9iMMHaZnFCqoxOKg= =/JxX -----END PGP SIGNATURE----- --t0UkRYy7tHLRMCai-- --===============0300487348== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0300487348==--