ChangeSet 1.1722.97.43, 2004/06/07 13:00:07-07:00, stern@rowland.harvard.edu [PATCH] USB: Fix logic in usb_get_descriptor() 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. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman drivers/usb/core/message.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c --- a/drivers/usb/core/message.c Fri Jun 18 11:01:15 2004 +++ b/drivers/usb/core/message.c Fri Jun 18 11:01:15 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;