libdrm: Handle usb_interface devices for usb parsing
authorScott Anderson <scott@anderso.nz>
Fri, 31 Jan 2020 03:18:19 +0000 (16:18 +1300)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 24 Apr 2020 08:53:53 +0000 (08:53 +0000)
commitbf63f8acdc94164ad29d1d56270964245b39f277
tree9e69372a0bdb27df7b2491adceaab996cbdeaf1d
parent57df07572ce45a1b60bae6fb89770388d3abd6dd
libdrm: Handle usb_interface devices for usb parsing

Currently the code expects that the device found at
/sys/char/$maj:$min/device for USB devices is a "usb_device". However,
at least for some devices, such as for the udl driver, they are instead
a "usb_interface".

A usb_interface is a child of the usb_device we're interested in, so we
walk up one in the /sys path to get there.

For example, with a USB device I have, trimmed to show the relevant
information:
```
$ udevadm info /dev/dri/card1
P: /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4:1.0/drm/card1
E: DEVTYPE=drm_minor
$ udevadm info /sys/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4:1.0
E: DEVTYPE=usb_interface
E: DRIVER=udl
$ udevadm info /sys/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4
E: DEVTYPE=usb_device
E: DRIVER=usb
E: BUSNUM=001
E: DEVNUM=009
```

Signed-off-by: Scott Anderson <scott@anderso.nz>
xf86drm.c