[U-Boot] [PATCH 02/16] usb: Stop reset procedure when a dev is handed over to a companion hcd

Hans de Goede hdegoede at redhat.com
Tue May 5 23:56:05 CEST 2015


Do not try to reset a device 5 times when it is handed over to a companion
controller, also do not print an error when it has been handed over.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 common/usb_hub.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/common/usb_hub.c b/common/usb_hub.c
index c9be530..499554b 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -168,8 +168,15 @@ int legacy_hub_port_reset(struct usb_device *dev, int port,
 	debug("%s: resetting port %d...\n", __func__, port + 1);
 #endif
 	for (tries = 0; tries < MAX_TRIES; tries++) {
-
+		int prev_companion_device_count = usb_companion_device_count;
 		usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET);
+		/*
+		 * If companion device count changed, the device was handed
+		 * over and we are done.
+		 */
+		if (usb_companion_device_count != prev_companion_device_count)
+			return -ENXIO;
+
 		mdelay(200);
 
 		if (usb_get_port_status(dev, port + 1, portsts) < 0) {
@@ -269,7 +276,8 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port)
 	/* Reset the port */
 	ret = legacy_hub_port_reset(dev, port, &portstatus);
 	if (ret < 0) {
-		printf("cannot reset port %i!?\n", port + 1);
+		if (ret != -ENXIO)
+			printf("cannot reset port %i!?\n", port + 1);
 		return ret;
 	}
 
-- 
2.3.6



More information about the U-Boot mailing list