From owner-p4-projects@FreeBSD.ORG Fri Oct 24 15:19:18 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5EB3C1065670; Fri, 24 Oct 2008 15:19:18 +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 08A74106566C for ; Fri, 24 Oct 2008 15:19:18 +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 EA8528FC14 for ; Fri, 24 Oct 2008 15:19:17 +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 m9OFJH8S056148 for ; Fri, 24 Oct 2008 15:19:17 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m9OFJHqT056146 for perforce@freebsd.org; Fri, 24 Oct 2008 15:19:17 GMT (envelope-from hselasky@FreeBSD.org) Date: Fri, 24 Oct 2008 15:19:17 GMT Message-Id: <200810241519.m9OFJHqT056146@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 151852 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, 24 Oct 2008 15:19:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=151852 Change 151852 by hselasky@hselasky_laptop001 on 2008/10/24 15:19:10 Patch to allow control requests while the USB FS is in use. Affected files ... .. //depot/projects/usb/src/lib/libusb20/libusb20.c#5 edit .. //depot/projects/usb/src/lib/libusb20/libusb20_int.h#4 edit .. //depot/projects/usb/src/lib/libusb20/libusb20_ugen20.c#4 edit Differences ... ==== //depot/projects/usb/src/lib/libusb20/libusb20.c#5 (text+ko) ==== @@ -558,6 +558,7 @@ pdev->pTransfer = NULL; } pdev->file = -1; + pdev->file_ctrl = -1; pdev->nTransfer = 0; } else { pdev->is_opened = 1; @@ -826,6 +827,7 @@ memset(pdev, 0, sizeof(*pdev)); pdev->file = -1; + pdev->file_ctrl = -1; pdev->methods = &libusb20_dummy_methods; return (pdev); } ==== //depot/projects/usb/src/lib/libusb20/libusb20_int.h#4 (text+ko) ==== @@ -219,6 +219,9 @@ /* device file handle */ int file; + /* device file handle (control transfers only) */ + int file_ctrl; + /* debugging level */ int debug; ==== //depot/projects/usb/src/lib/libusb20/libusb20_ugen20.c#4 (text+ko) ==== @@ -312,13 +312,24 @@ uint32_t plugtime; char buf[64]; int f; + int g; int error; snprintf(buf, sizeof(buf), "/dev/ugen%u.%u", pdev->bus_number, pdev->device_address); + /* + * We need two file handles, one for the control endpoint and one + * for BULK, INTERRUPT and ISOCHRONOUS transactions due to optimised + * kernel locking. + */ + g = open(buf, O_RDWR); + if (g < 0) { + return (LIBUSB20_ERROR_NO_DEVICE); + } f = open(buf, O_RDWR); if (f < 0) { + close(g); return (LIBUSB20_ERROR_NO_DEVICE); } if (ioctl(f, USB_GET_PLUGTIME, &plugtime)) { @@ -353,6 +364,7 @@ pdev->methods = &libusb20_ugen20_device_methods; pdev->privBeData = pfse; pdev->file = f; + pdev->file_ctrl = g; error = 0; done: if (error) { @@ -360,6 +372,7 @@ free(pfse); } close(f); + close(g); } return (error); } @@ -379,7 +392,9 @@ pdev->nTransfer = 0; pdev->privBeData = NULL; close(pdev->file); + close(pdev->file_ctrl); pdev->file = -1; + pdev->file_ctrl = -1; return (error); } @@ -403,7 +418,7 @@ gen_desc.ugd_maxlen = sizeof(cdesc); gen_desc.ugd_config_index = index; - error = ioctl(pdev->file, USB_GET_FULL_DESC, &gen_desc); + error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc); if (error) { return (LIBUSB20_ERROR_OTHER); } @@ -419,7 +434,7 @@ gen_desc.ugd_data = ptr; gen_desc.ugd_maxlen = len; - error = ioctl(pdev->file, USB_GET_FULL_DESC, &gen_desc); + error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc); if (error) { free(ptr); return (LIBUSB20_ERROR_OTHER); @@ -438,7 +453,7 @@ { int temp; - if (ioctl(pdev->file, USB_GET_CONFIG, &temp)) { + if (ioctl(pdev->file_ctrl, USB_GET_CONFIG, &temp)) { return (LIBUSB20_ERROR_OTHER); } *pindex = temp; @@ -451,7 +466,7 @@ { int temp = index; - if (ioctl(pdev->file, USB_SET_CONFIG, &temp)) { + if (ioctl(pdev->file_ctrl, USB_SET_CONFIG, &temp)) { return (LIBUSB20_ERROR_OTHER); } return (0); @@ -462,7 +477,7 @@ { int temp = iface_index; - if (ioctl(pdev->file, USB_CLAIM_INTERFACE, &temp)) { + if (ioctl(pdev->file_ctrl, USB_CLAIM_INTERFACE, &temp)) { return (LIBUSB20_ERROR_OTHER); } return (0); @@ -473,7 +488,7 @@ { int temp = iface_index; - if (ioctl(pdev->file, USB_RELEASE_INTERFACE, &temp)) { + if (ioctl(pdev->file_ctrl, USB_RELEASE_INTERFACE, &temp)) { return (LIBUSB20_ERROR_OTHER); } return (0); @@ -488,7 +503,7 @@ alt_iface.uai_interface_index = iface_index; alt_iface.uai_alt_index = alt_index; - if (ioctl(pdev->file, USB_SET_ALTINTERFACE, &alt_iface)) { + if (ioctl(pdev->file_ctrl, USB_SET_ALTINTERFACE, &alt_iface)) { return (LIBUSB20_ERROR_OTHER); } return (0); @@ -499,7 +514,7 @@ { int temp = 0; - if (ioctl(pdev->file, USB_DEVICEENUMERATE, &temp)) { + if (ioctl(pdev->file_ctrl, USB_DEVICEENUMERATE, &temp)) { return (LIBUSB20_ERROR_OTHER); } return (0); @@ -529,7 +544,7 @@ default: return (LIBUSB20_ERROR_INVALID_PARAM); } - if (ioctl(pdev->file, USB_SET_POWER_MODE, &temp)) { + if (ioctl(pdev->file_ctrl, USB_SET_POWER_MODE, &temp)) { return (LIBUSB20_ERROR_OTHER); } return (0); @@ -540,7 +555,7 @@ { int temp; - if (ioctl(pdev->file, USB_GET_POWER_MODE, &temp)) { + if (ioctl(pdev->file_ctrl, USB_GET_POWER_MODE, &temp)) { return (LIBUSB20_ERROR_OTHER); } switch (temp) { @@ -573,7 +588,7 @@ { int temp = iface_index; - if (ioctl(pdev->file, USB_IFACE_DRIVER_ACTIVE, &temp)) { + if (ioctl(pdev->file_ctrl, USB_IFACE_DRIVER_ACTIVE, &temp)) { return (LIBUSB20_ERROR_OTHER); } return (0); /* kernel driver is active */ @@ -585,7 +600,7 @@ { int temp = iface_index; - if (ioctl(pdev->file, USB_IFACE_DRIVER_DETACH, &temp)) { + if (ioctl(pdev->file_ctrl, USB_IFACE_DRIVER_DETACH, &temp)) { return (LIBUSB20_ERROR_OTHER); } return (0); /* kernel driver is active */ @@ -606,7 +621,7 @@ sizeof(req.ucr_request), setup)) { /* ignore */ } - if (ioctl(pdev->file, USB_DO_REQUEST, &req)) { + if (ioctl(pdev->file_ctrl, USB_DO_REQUEST, &req)) { return (LIBUSB20_ERROR_OTHER); } if (pactlen) {