Date: Mon, 17 Nov 2008 14:59:18 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 153087 for review Message-ID: <200811171459.mAHExI3e059885@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=153087 Change 153087 by hselasky@hselasky_laptop001 on 2008/11/17 14:59:00 Libusb20 improvements. Affected files ... .. //depot/projects/usb/src/lib/libusb20/libusb20_compat01.c#9 edit .. //depot/projects/usb/src/lib/libusb20/libusb20_ugen20.c#12 edit Differences ... ==== //depot/projects/usb/src/lib/libusb20/libusb20_compat01.c#9 (text+ko) ==== @@ -177,19 +177,42 @@ if (err) return (NULL); + /* + * Dequeue USB device from backend queue so that it does not get + * freed when the backend is re-scanned: + */ + libusb20_be_dequeue_device(usb_backend, dev->dev); + return (dev->dev); } int -usb_close(usb_dev_handle * dev) +usb_close(usb_dev_handle * udev) { + struct usb_device *dev; int err; - err = libusb20_dev_close((void *)dev); + err = libusb20_dev_close((void *)udev); if (err) return (-1); + if (usb_backend != NULL) { + /* + * Enqueue USB device to backend queue so that it gets freed + * when the backend is re-scanned: + */ + libusb20_be_enqueue_device(usb_backend, (void *)udev); + } else { + /* + * The backend is gone. Free device data so that we + * don't start leaking memory! + */ + dev = usb_device(udev); + libusb20_dev_free((void *)udev); + LIST_DEL(usb_global_bus.devices, dev); + free(dev); + } return (0); } @@ -697,7 +720,8 @@ /* "bConfigurationValue" not found */ return (-1); } - if ((dev->config + i)->bConfigurationValue == bConfigurationValue) { + if ((dev->config + i)->bConfigurationValue == + bConfigurationValue) { break; } } ==== //depot/projects/usb/src/lib/libusb20/libusb20_ugen20.c#12 (text+ko) ==== @@ -432,12 +432,11 @@ ugen20_close_device(struct libusb20_device *pdev) { struct usb2_fs_uninit fs_uninit; - int error = 0; if (pdev->privBeData) { memset(&fs_uninit, 0, sizeof(fs_uninit)); if (ioctl(pdev->file, USB_FS_UNINIT, &fs_uninit)) { - error = LIBUSB20_ERROR_OTHER; + /* ignore this error */ } free(pdev->privBeData); } @@ -447,7 +446,7 @@ close(pdev->file_ctrl); pdev->file = -1; pdev->file_ctrl = -1; - return (error); + return (0); /* success */ } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811171459.mAHExI3e059885>