[PATCH libdrm v3 3/5] xf86drm: Add platform and host1x bus support

Thierry Reding thierry.reding at gmail.com
Thu Jan 19 10:25:51 UTC 2017


Adding back dri-devel at 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 min,
> >  #endif
> >  }
> >  
> > +static void drmFreePlatformDevice(drmDevicePtr device)
> > +{
> > +    if (device->deviceinfo.platform) {
> 
> to save 2 indent level and improve readability :
> 
> if (! device->deviceinfo.platform ||
>     ! device->deviceinfo.platform->compatible)
> 	return;
> 
> > +        if (device->deviceinfo.platform->compatible) {
> > +            char **compatible = device->deviceinfo.platform->compatible;
> > +
> > +            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_deviceinfo,
> > +                                  uint32_t flags)
> > +{
> > +    drmDevicePtr dev;
> > +    char *ptr;
> > +    int ret;
> > +
> > +    dev = drmDeviceAlloc(node_type, node, sizeof(drmHost1xBusInfo),
> > +                         sizeof(drmHost1xDeviceInfo), &ptr);
> > +    if (!dev)
> > +        return -ENOMEM;
> > +
> > +    dev->bustype = DRM_BUS_HOST1X;
> > +
> > +    dev->businfo.host1x = (drmHost1xBusInfoPtr)ptr;
> > +
> > +    ret = drmParseHost1xBusInfo(maj, min, dev->businfo.host1x);
> > +    if (ret < 0)
> > +        goto free_device;
> > +
> > +    if (fetch_deviceinfo) {
> > +        ptr += sizeof(drmHost1xBusInfo);
> > +        dev->deviceinfo.host1x = (drmHost1xDeviceInfoPtr)ptr;
> > +
> > +        ret = drmParseHost1xDeviceInfo(maj, min, dev->deviceinfo.host1x);
> > +        if (ret < 0)
> > +            goto free_device;
> > +    }
> > +
> > +    *device = dev;
> > +
> 
> do you assume that fetch_deviceinfo may change dev ?

No, why?

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20170119/175836ba/attachment.sig>


More information about the xorg-devel mailing list