PERFORCE change 151812 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Thu Oct 23 16:06:39 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=151812
Change 151812 by hselasky at hselasky_laptop001 on 2008/10/23 16:06:30
Some fixes for LibUSB v0.1.12 compat layer.
Affected files ...
.. //depot/projects/usb/src/lib/libusb20/libusb20.c#4 edit
.. //depot/projects/usb/src/lib/libusb20/libusb20_compat01.c#2 edit
Differences ...
==== //depot/projects/usb/src/lib/libusb20/libusb20.c#4 (text+ko) ====
@@ -661,7 +661,12 @@
* We need to read the USB string in two steps else some USB
* devices will complain.
*/
- req.wValue = (256 * LIBUSB20_DT_STRING) | index;
+ req.bmRequestType =
+ LIBUSB20_REQUEST_TYPE_STANDARD |
+ LIBUSB20_RECIPIENT_DEVICE |
+ LIBUSB20_ENDPOINT_IN;
+ req.bRequest = LIBUSB20_REQUEST_GET_DESCRIPTOR;
+ req.wValue = (LIBUSB20_DT_STRING << 8) | index;
req.wIndex = langid;
req.wLength = 4; /* bytes */
@@ -702,10 +707,16 @@
/* the following code derives from the FreeBSD USB kernel */
- if (len < 1) {
+ if ((len < 1) || (ptr == NULL)) {
/* too short buffer */
return (LIBUSB20_ERROR_INVALID_PARAM);
}
+ /*
+ * Make sure that there is sensible contents in the buffer in case
+ * of an error:
+ */
+ *(uint8_t *)ptr = 0;
+
error = libusb20_dev_req_string_sync(pdev,
0, 0, temp, sizeof(temp));
if (error < 0)
==== //depot/projects/usb/src/lib/libusb20/libusb20_compat01.c#2 (text+ko) ====
@@ -213,7 +213,7 @@
if (err)
return (-1);
- return (0);
+ return (strlen(buf));
}
int
@@ -340,11 +340,12 @@
bifc->bDescriptorType = aifc->desc.bDescriptorType;
bifc->bInterfaceNumber = aifc->desc.bInterfaceNumber;
bifc->bAlternateSetting = aifc->desc.bAlternateSetting;
- bifc->bNumEndpoints = aifc->desc.bNumEndpoints;
+ bifc->bNumEndpoints = aifc->num_endpoints;
bifc->bInterfaceClass = aifc->desc.bInterfaceClass;
bifc->bInterfaceSubClass = aifc->desc.bInterfaceSubClass;
bifc->bInterfaceProtocol = aifc->desc.bInterfaceProtocol;
bifc->iInterface = aifc->desc.iInterface;
+ bifc->endpoint = ps->b.currep;
}
for (x = 0; x != aifc->num_endpoints; x++) {
ps->a.currep = aifc->endpoints + x;
@@ -365,13 +366,14 @@
aifc = ps->a.currifc;
bifc = ps->b.currifcw++;
- usb_parse_iface_sub(ps);
if (ps->preparse == 0) {
/* initialise interface wrapper */
bifc->altsetting = ps->b.currifc;
bifc->num_altsetting = aifc->num_altsetting + 1;
}
+ usb_parse_iface_sub(ps);
+
for (x = 0; x != aifc->num_altsetting; x++) {
ps->a.currifc = aifc->altsetting + x;
usb_parse_iface_sub(ps);
@@ -780,6 +782,7 @@
struct usb_device *udev;
struct LIBUSB20_DEVICE_DESC_DECODED *ddesc;
struct libusb20_backend *pold;
+ int err;
/* cleanup after last device search */
@@ -852,6 +855,12 @@
udev->dev = pdev;
pdev->priv01Data = udev;
+ err = libusb20_dev_open(pdev, 0);
+ if (err == 0) {
+ /* XXX get all config descriptors by default */
+ usb_fetch_and_parse_descriptors((void *)pdev);
+ libusb20_dev_close(pdev);
+ }
LIST_ADD(usb_global_bus.devices, udev);
}
More information about the p4-projects
mailing list