diff mbox

[U-Boot,v2] dm: usb: Do not reprobe usb hosts on "usb tree" command

Message ID 1459634679-22194-1-git-send-email-hdegoede@redhat.com
State Accepted
Commit 192eab9357473e09218e0a4448b220d691d9d886
Delegated to: Marek Vasut
Headers show

Commit Message

Hans de Goede April 2, 2016, 10:04 p.m. UTC
Some usb hosts may have failed to probe on "usb start", i.e. an otg
host without an otg-host cable plugged in.

"usb tree" would cause the probe method of these hosts to get called
again, something which should only happen on "usb reset".

This commit fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Add missing #include for uclass_find_first_device/uclass_find_next_device
---
 cmd/usb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Simon Glass April 9, 2016, 6:35 p.m. UTC | #1
On 2 April 2016 at 16:04, Hans de Goede <hdegoede@redhat.com> wrote:
> Some usb hosts may have failed to probe on "usb start", i.e. an otg
> host without an otg-host cable plugged in.
>
> "usb tree" would cause the probe method of these hosts to get called
> again, something which should only happen on "usb reset".
>
> This commit fixes this.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2:
> -Add missing #include for uclass_find_first_device/uclass_find_next_device
> ---
>  cmd/usb.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/cmd/usb.c b/cmd/usb.c
index 9ed5dc6..719f6f2 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -15,6 +15,7 @@ 
 #include <command.h>
 #include <console.h>
 #include <dm.h>
+#include <dm/uclass-internal.h>
 #include <memalign.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
@@ -442,12 +443,15 @@  void usb_show_tree(void)
 #ifdef CONFIG_DM_USB
 	struct udevice *bus;
 
-	for (uclass_first_device(UCLASS_USB, &bus);
+	for (uclass_find_first_device(UCLASS_USB, &bus);
 		bus;
-		uclass_next_device(&bus)) {
+		uclass_find_next_device(&bus)) {
 		struct usb_device *udev;
 		struct udevice *dev;
 
+		if (!device_active(bus))
+			continue;
+
 		device_find_first_child(bus, &dev);
 		if (dev && device_active(dev)) {
 			udev = dev_get_parent_priv(dev);