Date: Fri, 24 Oct 2008 15:19:17 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 151852 for review Message-ID: <200810241519.m9OFJHqT056146@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810241519.m9OFJHqT056146>