Re: [PATCH] USB-Core, fix cardreader not found during init

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Mon, 13 Aug 2007, Steffen Koepf wrote:

> From: Steffen Koepf <[email protected]>
> 
> There is a USB-Device Init-Problem with the Apacer AE161 USB-Cardreader,
> which contains the Chip AU6375. The Cardreader init fails in about 50%
> of system boots, with the following lines:
> 
> usb 1-6: unable to read config index 0 descriptor/all
> usb 1-6: can't read configurations, error -71
> hub 1-0:1.0: Cannot enable port 6.  Maybe the USB cable is bad?
> 
> The patch let's the kernel stay in the loop if a usb_control_msg() fails, 
> the cardreader is detected properly and the loop is never executed more
> than two times. The second call of usb_control_msg succeeds always. Maybe 
> it was the developer's goal of the loop to fix such things?
> Kernel: 2.6.22.2
> 
> Signed-off-by: Steffen Koepf <[email protected]>
> 
> ---
> --- linux-2.6.22.2/drivers/usb/core/message.c.orig	Mon Aug 13 22:12:34 2007
> +++ linux-2.6.22.2/drivers/usb/core/message.c	Mon Aug 13 22:12:52 2007
> @@ -634,6 +634,8 @@ int usb_get_descriptor(struct usb_device
>  			result = -EPROTO;
>  			continue;
>  		}
> +		if (result < 0)
> +			continue;
>  		break;
>  	}
>  	return result;

This patch is the wrong way to do it.  You should try this patch 
instead.

Alan Stern


Index: 2.6.22/drivers/usb/core/message.c
===================================================================
--- 2.6.22.orig/drivers/usb/core/message.c
+++ 2.6.22/drivers/usb/core/message.c
@@ -623,12 +623,12 @@ int usb_get_descriptor(struct usb_device
 	memset(buf,0,size);	// Make sure we parse really received data
 
 	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),
 				USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
 				(type << 8) + index, 0, buf, size,
 				USB_CTRL_GET_TIMEOUT);
-		if (result == 0 || result == -EPIPE)
+		if (result <= 0)
 			continue;
 		if (result > 1 && ((u8 *)buf)[1] != type) {
 			result = -EPROTO;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.