ChangeSet 1.1722.97.43, 2004/06/07 13:00:07-07:00, [EMAIL PROTECTED]
[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 <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
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;
-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel