linux: Set device->port_number

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
linux: Improve topology related debug messages

And use usbi_dbg, rather then fprintf(stderr, ...

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
linux: Not finding a device on hotplug_disconnect is not an error

This can happen if the device gets removed between registering the hot-plug
event handler and initial device enumeration running. So lets turn this
into a debug message to avoid spurious bug-reports.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
linux: Replace should-not-happen checks with asserts

These all really should never happen, so rather then to do error handling
when they do, simple assert them.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
linux_udev: linux_start_event_monitor: Properly cleanup on error

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
linux: Fixup init_count tracking on hotplug init error

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
core: Improve error / debug messages for hotplug pipe handling

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
All: ref dev->parent_dev

An app can hold a reference to just a leave device, if then an entire
hub goes away, all removed devices will get there final unref, except for
the one ref-ed by the app. If the app then tries to use parent_dev in anyway
after this, we've a use-after-free bug. This fixes this.

Also remove the lets re-enumerate fix for this from libusb_get_port_path,
I'm not sure what the exact idea behind this fix was, but after this patch
it is no longer needed, and this patch also fixes usage of for example
libusb_get_parent().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
listdevs: Also print portpath for non root hubs

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
linux: linux_get_parent_info: properly propagate malloc errors

Signed-off-by: Hans de Goede <hdegoede@redhat.com>