Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jun 2009 19:19:47 GMT
From:      Sylvestre Gallon <syl@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 165272 for review
Message-ID:  <200906261919.n5QJJlhL060110@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165272

Change 165272 by syl@syl_atuin on 2009/06/26 19:18:47

	Fix problem spotted by Hans Petter Selasky :
	- Add a missing break for libusb_open_device_with_vid_pid().
	- Call libusb20_dev_close before libusb_unref_device().
	- Implement libusb_set_configuration() funtion the right way.

Affected files ...

.. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#47 edit

Differences ...

==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#47 (text+ko) ====

@@ -444,9 +444,11 @@
 		pdev = (struct libusb20_device *)devs[j]->os_priv;
 		pdesc = libusb20_dev_get_device_desc(pdev);
 		if (pdesc->idVendor == vendor_id &&
-		    pdesc->idProduct == product_id)
+		    pdesc->idProduct == product_id) {
 			if (libusb_open(devs[j], &devh) < 0)
 				devh = NULL;
+			break ;
+		}
 	}
 
 	libusb_free_device_list(devs, 1);
@@ -483,8 +485,8 @@
 		pthread_mutex_unlock(&ctx->open_devs_lock);
 
 		usb_remove_pollfd(ctx, libusb20_dev_get_fd(pdev));
+		libusb20_dev_close(pdev);
 		libusb_unref_device(devh->dev);
-		libusb20_dev_close(pdev);
 		free(devh);
 
 		pthread_mutex_lock(&ctx->pollfd_modify_lock);
@@ -500,8 +502,8 @@
 	pthread_mutex_unlock(&ctx->open_devs_lock);
 
 	usb_remove_pollfd(ctx, libusb20_dev_get_fd(pdev));
+	libusb20_dev_close(pdev);
 	libusb_unref_device(devh->dev);
-	libusb20_dev_close(pdev);
 	free(devh);
 
 	pthread_mutex_lock(&ctx->pollfd_modify_lock);
@@ -547,10 +549,6 @@
 	return (0);
 }
 
-/*
- *	XXX this code is wrong. need update.
- */
-
 int
 libusb_set_configuration(libusb_device_handle * devh, int configuration)
 {
@@ -566,8 +564,7 @@
 
 	pdev = (struct libusb20_device *)devh->dev->os_priv;
 
-	libusb20_dev_set_alt_index(pdev, libusb20_dev_get_config_index(pdev),
-	    configuration);
+	libusb20_dev_set_config_index(pdev, configuration);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration leave");
 	return (0);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906261919.n5QJJlhL060110>