PERFORCE change 161830 for review

Sylvestre Gallon syl at FreeBSD.org
Sat May 9 13:24:03 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=161830

Change 161830 by syl at syl_atuin on 2009/05/09 13:23:55

	- Implement libusb_attach_kernel_driver.
	- Implement libusb_set_interface_alt_setting.
	- Implement libusb_clear_halt.

Affected files ...

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

Differences ...

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

@@ -163,14 +163,13 @@
 	int i;
 
 	if (list == NULL)
-		return (NULL);
+		return ;
 
 	for (i = 0; list[i] != NULL; i++) {
 		libusb_unref_device(list[i]);
 	}
 
 	free(list);
-	return;
 }
 
 uint8_t
@@ -347,7 +346,7 @@
 int
 libusb_get_configuration(libusb_device_handle * devh, int *config)
 {
-	if (devh == NULL)
+	if (devh == NULL || config == NULL)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
 	*config = libusb20_dev_get_config_index((struct libusb20_device *)
@@ -377,6 +376,9 @@
 {
 	int ret = 0;
 
+	if (dev == NULL)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+
 	if (interface_number >= sizeof(dev->claimed_interfaces) * 8)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
@@ -396,6 +398,9 @@
 {
 	int ret;
 
+	if (dev == NULL)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+
 	if (interface_number >= sizeof(dev->claimed_interfaces) * 8)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 
@@ -414,12 +419,35 @@
 libusb_set_interface_alt_setting(libusb_device_handle * dev,
     int interface_number, int alternate_setting)
 {
+	int ret;
+
+	if (dev == NULL)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+
+	if (interface_number >= sizeof(dev->claimed_interfaces) *8)
+		return (LIBUSB_ERROR_INVALID_PARAM);
+
+	pthread_mutex_lock(&dev->lock);
+	if (!(dev->claimed_interfaces & (1 << interface_number))) {
+		pthread_mutex_unlock(&dev->lock);
+		return (LIBUSB_ERROR_NOT_FOUND);
+	}
+	pthread_mutex_unlock(&dev->lock);
+
+	if (libusb20_dev_set_alt_index(dev->os_priv, interface_number,
+	    alternate_setting) != 0)
+		return (LIBUSB_ERROR_OTHER);
+	
 	return (0);
 }
 
 int
 libusb_clear_halt(libusb_device_handle * dev, unsigned char endpoint)
 {
+	struct libusb20_transfer xfer;
+
+	libusb20_tr_open(&xfer, 0, 0, endpoint);
+	libusb20_tr_clear_stall_sync(&xfer);
 	return (0);
 }
 
@@ -457,7 +485,10 @@
 }
 
 
-/* XXX Perhaps need some work on ugen to be implemented */
+/* 
+ * stub function.
+ * libusb20 doesn't support this feature.
+ */
 int
 libusb_attach_kernel_driver(libusb_device_handle * devh, int interface)
 {


More information about the p4-projects mailing list