patch-2.3.1 linux/drivers/usb/usb.c

Next file: linux/drivers/usb/usb.h
Previous file: linux/drivers/usb/uhci.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.0/linux/drivers/usb/usb.c linux/drivers/usb/usb.c
@@ -124,7 +124,7 @@
 			
 		if (n_len < 2 || n_len > len)
 		{
-			printk("Short descriptor.\n");
+			printk("Short descriptor\n");
 			return -1;
 		}
 		printk(
@@ -152,9 +152,12 @@
 {
 	int n_len = ptr[0];
 
+	if (len <= 0)
+		return -1;
+
 	if (n_len < 2 || n_len > len)
 	{
-		printk("Short descriptor.\n");
+		printk("Short descriptor. (%d, %d)\n", len, n_len);
 		return -1;
 	}
 
@@ -247,6 +250,11 @@
 	len -= *ptr;
 	parsed += *ptr;
 
+	if (config->MaxPower == 200) {
+		printk("bNumInterfaces kludge\n");
+		config->bNumInterfaces += 3;
+	}
+
 	if (config->bNumInterfaces > USB_MAXINTERFACES)
 	{
 		printk(KERN_WARNING "usb: too many interfaces.\n");
@@ -298,8 +306,10 @@
 		if (retval < 0)
 			return retval;
 		ptr += retval;
-		bytes += retval;
+		bytes -= retval;
 	}
+	if (bytes)
+		printk(KERN_WARNING "usb: %d bytes of extra configuration data left\n", bytes);
 	return 0;
 }
 
@@ -533,6 +543,23 @@
 
 	return 0;
 }
+
+int usb_set_interface(struct usb_device *dev, int interface, int alternate)
+{
+	devrequest dr;
+
+	dr.requesttype = 1;
+	dr.request = USB_REQ_SET_INTERFACE;
+	dr.value = alternate;
+	dr.index = interface;
+	dr.length = 0;
+
+	if (dev->bus->op->control_msg(dev, usb_sndctrlpipe(dev, 0), &dr, NULL, 0))
+		return -1;
+
+	return 0;
+}
+
 
 int usb_set_configuration(struct usb_device *dev, int configuration)
 {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)