PERFORCE change 153028 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sun Nov 16 03:55:20 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=153028
Change 153028 by hselasky at hselasky_laptop001 on 2008/11/16 11:54:26
Fix problem with dfu-util and libusb.
Affected files ...
.. //depot/projects/usb/src/lib/libusb20/libusb20_compat01.c#8 edit
Differences ...
==== //depot/projects/usb/src/lib/libusb20/libusb20_compat01.c#8 (text+ko) ====
@@ -821,36 +821,28 @@
struct libusb20_device *pdev;
struct usb_device *udev;
struct LIBUSB20_DEVICE_DESC_DECODED *ddesc;
- struct libusb20_backend *pold;
int err;
/* cleanup after last device search */
+ /* close all opened devices, if any */
- pold = usb_backend;
-
- pdev = NULL;
- while ((pdev = libusb20_be_device_foreach(pold, pdev))) {
- if (!pdev->is_opened) {
- /*
- * if the device has not been opened we free the
- * device data
- */
- udev = pdev->priv01Data;
- libusb20_be_dequeue_device(pold, pdev);
- libusb20_dev_free(pdev);
- if (udev != NULL) {
- LIST_DEL(usb_global_bus.devices, udev);
- free(udev);
- }
- pdev = NULL; /* restart search */
+ while ((pdev = libusb20_be_device_foreach(usb_backend, NULL))) {
+ udev = pdev->priv01Data;
+ libusb20_be_dequeue_device(usb_backend, pdev);
+ libusb20_dev_free(pdev);
+ if (udev != NULL) {
+ LIST_DEL(usb_global_bus.devices, udev);
+ free(udev);
}
}
+ /* free old USB backend, if any */
+
+ libusb20_be_free(usb_backend);
+
/* do a new backend device search */
-
usb_backend = libusb20_be_alloc_default();
if (usb_backend == NULL) {
- usb_backend = pold; /* restore */
return (-1);
}
/* iterate all devices */
@@ -904,17 +896,6 @@
LIST_ADD(usb_global_bus.devices, udev);
}
- /* move old devices over to the new USB backend */
-
- while ((pdev = libusb20_be_device_foreach(pold, pdev))) {
- libusb20_be_dequeue_device(pold, pdev);
- libusb20_be_enqueue_device(usb_backend, pdev);
- }
-
- /* free old backend, if any */
-
- libusb20_be_free(pold);
-
return (0); /* success */
}
More information about the p4-projects
mailing list