Use new GUsb functionality to fix flashing Unifying devices

This avoids open()ing and close()ing multiple times on hotplug -- which in
itself isn't a huge problem as the requests are refcounted in libusb, but it
matters hugely when a plugin accidentally closes a device that was not opened.

As all the devices are going to be opened anyway (to read the vendor strings)
and the cost of keeping the device is open is tiny, just get libgusb to
auto-open *all* devices and keep them open for the duration.

Fixes: https://github.com/hughsie/fwupd/issues/155
This commit is contained in:
Richard Hughes 2017-07-22 21:07:42 +01:00
parent f592b06722
commit 1ad45caeec

View File

@ -2419,6 +2419,10 @@ fu_engine_load (FuEngine *self, GError **error)
g_prefix_error (error, "Failed to get USB context: ");
return FALSE;
}
#if G_USB_CHECK_VERSION(0,2,11)
g_usb_context_set_flags (self->usb_ctx,
G_USB_CONTEXT_FLAGS_AUTO_OPEN_DEVICES);
#endif
#if AS_CHECK_VERSION(0,6,13)
/* load the hwids */