Commit 945fef15 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 554b4fbd
......@@ -566,18 +566,18 @@ void usb_sg_cancel (struct usb_sg_request *io)
*/
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),
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)
HZ * USB_CTRL_GET_TIMEOUT);
if (!(result == 0 || result == -EPIPE))
break;
}
return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment