From owner-p4-projects@FreeBSD.ORG Thu Oct 23 16:06:39 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E9BFA1065680; Thu, 23 Oct 2008 16:06:38 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C03A1065679 for ; Thu, 23 Oct 2008 16:06:38 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7AB928FC19 for ; Thu, 23 Oct 2008 16:06:38 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m9NG6cwn036062 for ; Thu, 23 Oct 2008 16:06:38 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m9NG6ck3036060 for perforce@freebsd.org; Thu, 23 Oct 2008 16:06:38 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 23 Oct 2008 16:06:38 GMT Message-Id: <200810231606.m9NG6ck3036060@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 151812 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Oct 2008 16:06:39 -0000 http://perforce.freebsd.org/chv.cgi?CH=151812 Change 151812 by hselasky@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); }