Greg:

This patch fixes a simple logic error in usb_get_descriptor().  It also 
takes the opportunity to make the subroutine a little easier to read.  
Please apply.

Stephen:

Thanks for pointing out the problem and testing the patch.

Alan Stern



Signed-off-by: Alan Stern <[EMAIL PROTECTED]>

--- usb-2.6/drivers/usb/core/message.c  Fri Jun  4 09:59:16 2004
+++ usb-2.6/drivers/usb/core/message.c  Sun Jun  6 16:43:22 2004
@@ -566,18 +566,18 @@
  */
 int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char 
index, void *buf, int size)
 {
-       int i = 3;
+       int i;
        int result;
        
        memset(buf,0,size);     // Make sure we parse really received data
 
-       while (i--) {
+       for (i = 0; i < 3; ++i) {
                /* retry on length 0 or stall; some devices are flakey */
-               if ((result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-                                   USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
-                                   (type << 8) + index, 0, buf, size,
-                                   HZ * USB_CTRL_GET_TIMEOUT)) > 0
-                               || result != -EPIPE)
+               result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
+                               USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
+                               (type << 8) + index, 0, buf, size,
+                               HZ * USB_CTRL_GET_TIMEOUT);
+               if (!(result == 0 || result == -EPIPE))
                        break;
        }
        return result;



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to