linux: Deal with devices being enumerated before their parents are
authorHans de Goede <hdegoede@redhat.com>
Thu, 16 May 2013 15:13:11 +0000 (17:13 +0200)
committerHans de Goede <hdegoede@redhat.com>
Thu, 16 May 2013 15:18:33 +0000 (17:18 +0200)
commitcf46b17f8287c1a6650687ad4f84bb05fbbe213e
tree28a8c67ed9c73e9d59e471953b04e64016876b3f
parentf168b3d23f8cff5d5986ddbd7c0dffcd5cb91347
linux: Deal with devices being enumerated before their parents are

The linux netlink enumeration code processes devices in readdir order, which
means devices may get enumerated before their parent is, IE on my system
readdir order is (ls -U)
1-1   usb4       2-1.8        6-0:1.0    1-1.4.3    1-1.4.4.1:1.0
2-1   usb5       6-1.4        6-1:1.0    1-1.4.4    1-1.4.4.1:1.1
6-1   usb6       3-0:1.0      2-1.8:1.0  1-0:1.0    1-1.4.4.1:1.2
7-1   usb7       1-1.4.3:1.0  2-1.8:1.1  1-1:1.0
usb1  1-1.4.4.1  1-1.4.4:1.0  2-1.8:1.2  6-1.4:1.0
usb2  1-1.4:1.0  4-0:1.0      7-0:1.0    2-0:1.0
usb3  1-1.4      5-0:1.0      7-1:1.0    2-1:1.0

So 1.4.4.1 will get added (way) before 1.4.4 and indeed:
[ 0.002243] [00004055] libusbx: debug [linux_get_device_address] scan 1-1.4.4.1
Dev 0x1973bc0 (1-1.4.4.1) has parent (nil)

This patch fixes this by forcing enumeration of the parent from
linux_parent_dev.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/os/linux_usbfs.c
libusb/version_nano.h