Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c39772d8 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

USB: allow retry on descriptor fetch errors



This patch (as964) was suggested by Steffen Koepf.  It makes
usb_get_descriptor() retry on all errors other than ETIMEDOUT, instead
of only on EPIPE.  This helps with some devices.

Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
CC: stable <stable@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3b79cc26
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -637,12 +637,12 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char
	memset(buf,0,size);	// Make sure we parse really received data
	memset(buf,0,size);	// Make sure we parse really received data


	for (i = 0; i < 3; ++i) {
	for (i = 0; i < 3; ++i) {
		/* retry on length 0 or stall; some devices are flakey */
		/* retry on length 0 or error; some devices are flakey */
		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,
				USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
				(type << 8) + index, 0, buf, size,
				(type << 8) + index, 0, buf, size,
				USB_CTRL_GET_TIMEOUT);
				USB_CTRL_GET_TIMEOUT);
		if (result == 0 || result == -EPIPE)
		if (result <= 0 && result != -ETIMEDOUT)
			continue;
			continue;
		if (result > 1 && ((u8 *)buf)[1] != type) {
		if (result > 1 && ((u8 *)buf)[1] != type) {
			result = -EPROTO;
			result = -EPROTO;