diff mbox series

[RFC,3/3] common/usb.c: Work around keyboard reporting "USB device not accepting new address"

Message ID 20200625151025.84435-4-jason.wessel@windriver.com
State Superseded
Delegated to: Marek Vasut
Headers show
Series Improve USB Keyboard support for rpi3/rpi4 | expand

Commit Message

Jason Wessel June 25, 2020, 3:10 p.m. UTC
When resetting the rpi3 board sometimes it will display:
     USB device not accepting new address (error=0)

After the message appears, the usb keyboard will not work.  It seems
that the configuration actually did succeed however.  Checking the
device status for a return code of zero and continuing allows the usb
keyboard and other usb devices to work function.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
 common/usb.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Matthias Brugger June 26, 2020, 10 a.m. UTC | #1
On 25/06/2020 17:10, Jason Wessel wrote:
> When resetting the rpi3 board sometimes it will display:
>      USB device not accepting new address (error=0)
> 
> After the message appears, the usb keyboard will not work.  It seems
> that the configuration actually did succeed however.  Checking the
> device status for a return code of zero and continuing allows the usb
> keyboard and other usb devices to work function.
> 
> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
> ---
>  common/usb.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/common/usb.c b/common/usb.c
> index aad13fd9c5..2f7f205444 100644
> --- a/common/usb.c
> +++ b/common/usb.c
> @@ -1054,11 +1054,13 @@ static int usb_prepare_device(struct usb_device *dev, int addr, bool do_read,
>  	dev->devnum = addr;
>  
>  	err = usb_set_address(dev); /* set address */
> -
> -	if (err < 0) {
> -		printf("\n      USB device not accepting new address " \
> +	if (err < 0)
> +		debug("\n       usb_set_address return < 0\n");
> +	if (err < 0 && dev->status != 0) {
> +		printf("\n      USB device not accepting new address "	\
>  			"(error=%lX)\n", dev->status);
> -		return err;
> +		if (dev->status != 0)

Always true as you already checked "dev->status != 0" in the first if.

Regards,
Matthias

> +			return err;
>  	}
>  
>  	mdelay(10);	/* Let the SET_ADDRESS settle */
>
diff mbox series

Patch

diff --git a/common/usb.c b/common/usb.c
index aad13fd9c5..2f7f205444 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -1054,11 +1054,13 @@  static int usb_prepare_device(struct usb_device *dev, int addr, bool do_read,
 	dev->devnum = addr;
 
 	err = usb_set_address(dev); /* set address */
-
-	if (err < 0) {
-		printf("\n      USB device not accepting new address " \
+	if (err < 0)
+		debug("\n       usb_set_address return < 0\n");
+	if (err < 0 && dev->status != 0) {
+		printf("\n      USB device not accepting new address "	\
 			"(error=%lX)\n", dev->status);
-		return err;
+		if (dev->status != 0)
+			return err;
 	}
 
 	mdelay(10);	/* Let the SET_ADDRESS settle */