From owner-p4-projects@FreeBSD.ORG Fri Nov 7 18:27:37 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 35DB4106568D; Fri, 7 Nov 2008 18:27:37 +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 EE500106568A for ; Fri, 7 Nov 2008 18:27:36 +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 DCF3D8FC14 for ; Fri, 7 Nov 2008 18:27:36 +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 mA7IRavN017120 for ; Fri, 7 Nov 2008 18:27:36 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mA7IRaHB017118 for perforce@freebsd.org; Fri, 7 Nov 2008 18:27:36 GMT (envelope-from hselasky@FreeBSD.org) Date: Fri, 7 Nov 2008 18:27:36 GMT Message-Id: <200811071827.mA7IRaHB017118@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 152628 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: Fri, 07 Nov 2008 18:27:37 -0000 http://perforce.freebsd.org/chv.cgi?CH=152628 Change 152628 by hselasky@hselasky_laptop001 on 2008/11/07 18:27:23 Libusb-0.1.12 compatibility issue: Need to translate from "bConfigurationValue" to configuration index when setting the configuration. The error was indirectly reported by Stefan Ehmann. Affected files ... .. //depot/projects/usb/src/lib/libusb20/libusb20_compat01.c#7 edit .. //depot/projects/usb/src/usr.sbin/usbconfig/usbconfig.c#6 edit Differences ... ==== //depot/projects/usb/src/lib/libusb20/libusb20_compat01.c#7 (text+ko) ==== @@ -670,11 +670,40 @@ } int -usb_set_configuration(usb_dev_handle * dev, int configuration) +usb_set_configuration(usb_dev_handle * udev, int bConfigurationValue) { + struct usb_device *dev; int err; + uint8_t i; + + /* + * Need to translate from "bConfigurationValue" to + * configuration index: + */ - err = libusb20_dev_set_config_index((void *)dev, configuration); + if (bConfigurationValue == 0) { + /* unconfigure */ + i = 255; + } else { + /* lookup configuration index */ + dev = usb_device(udev); + + /* check if the configuration array is not there */ + if (dev->config == NULL) { + return (-1); + } + for (i = 0;; i++) { + if (i == dev->descriptor.bNumConfigurations) { + /* "bConfigurationValue" not found */ + return (-1); + } + if ((dev->config + i)->bConfigurationValue == bConfigurationValue) { + break; + } + } + } + + err = libusb20_dev_set_config_index((void *)udev, i); if (err) return (-1); ==== //depot/projects/usb/src/usr.sbin/usbconfig/usbconfig.c#6 (text+ko) ==== @@ -266,8 +266,8 @@ "usbconfig - configure the USB subsystem" "\n" "usage: usbconfig -u -a -i [cmds...]" "\n" "commands:" "\n" - " set_config " "\n" - " set_alt " "\n" + " set_config " "\n" + " set_alt " "\n" " set_owner " "\n" " set_perm " "\n" " add_dev_quirk_vplh " "\n"