Skip to contentSkip to conversation

usb: host: Print device name when scanning

PATCH New Ismael Luceno Cortes 2 participants 2 messages Mar 19, 2019 – Mar 21, 2019 USB

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 usb: host: Print device name when scanning

Drop the counter, it has no meaning other than being the order in which the interface is found; the name assigned to the USB host controller interface is a better indicator.

Example of the original output:

Quoted 3 lines

USB0: USB EHCI 1.10
scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

Patched output:

Quoted 3 lines

Bus usb at ee080100: USB EHCI 1.10
scanning bus usb at ee080100 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

---

Notes:
Changes since v3:
- Replaced dev->seq with dev->name in usb_scan_bus

Changes since v2:
- Dropped counter altogether.

Changes since v1:
- Improved commit message.

 drivers/usb/host/usb-uclass.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/usb/host/usb-uclass.c +4 -8
index 611ea97a72..6e118b5a8f 100644
@@ -210,7 +210,7 @@ static void usb_scan_bus(struct udevice *bus, bool recurse)
 
 	assert(recurse);	/* TODO: Support non-recusive */
 
-	printf("scanning bus %d for devices... ", bus->seq);
+	printf("scanning bus %s for devices... ", bus->name);
 	debug("\n");
 	ret = usb_scan_device(bus, 0, USB_SPEED_FULL, &dev);
 	if (ret)
@@ -242,7 +242,6 @@ int usb_init(void)
 	struct usb_bus_priv *priv;
 	struct udevice *bus;
 	struct uclass *uc;
-	int count = 0;
 	int ret;
 
 	asynch_allowed = 1;
@@ -255,8 +254,7 @@ int usb_init(void)
 
 	uclass_foreach_dev(bus, uc) {
 		/* init low_level USB */
-		printf("USB%d:   ", count);
-		count++;
+		printf("Bus %s: ", bus->name);
 
 #ifdef CONFIG_SANDBOX
 		/*
@@ -327,10 +325,8 @@ int usb_init(void)
 	remove_inactive_children(uc, bus);
 
 	/* if we were not able to find at least one working bus, bail out */
-	if (!count)
-		printf("No controllers found\n");
-	else if (controllers_initialized == 0)
-		printf("USB error: all controllers failed lowlevel init\n");
+	if (controllers_initialized == 0)
+		printf("No working controllers found\n");
 
 	return usb_started ? 0 : -1;
 }

base-commit: 9ba5e5bc261a16f51662490da0cf620dc7f29013
prerequisite-patch-id: 8ebbc14087da985e5db35ef02335fbfdb4add60a

Signature · 1 line
2.19.1
Applied
#1 lore raw

PATCH v4 1/1 usb: host: Print device name when scanning

Quoted 64 lines · Ismael Luceno Cortes

Drop the counter, it has no meaning other than being the order in which the interface is found; the name assigned to the USB host controller interface is a better indicator.

Example of the original output:

Quoted 3 lines

USB0: USB EHCI 1.10
scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

Patched output:

Quoted 3 lines

Bus usb at ee080100: USB EHCI 1.10
scanning bus usb at ee080100 for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found

---

Notes:
Changes since v3:
- Replaced dev->seq with dev->name in usb_scan_bus

Changes since v2:
- Dropped counter altogether.

Changes since v1:
- Improved commit message.

 drivers/usb/host/usb-uclass.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/usb/host/usb-uclass.c +2 -4
index 611ea97a72..6e118b5a8f 100644
@@ -210,7 +210,7 @@ static void usb_scan_bus(struct udevice *bus, bool recurse)
 
 	assert(recurse);	/* TODO: Support non-recusive */
 
-	printf("scanning bus %d for devices... ", bus->seq);
+	printf("scanning bus %s for devices... ", bus->name);
 	debug("\n");
 	ret = usb_scan_device(bus, 0, USB_SPEED_FULL, &dev);
 	if (ret)
@@ -242,7 +242,6 @@ int usb_init(void)
 	struct usb_bus_priv *priv;
 	struct udevice *bus;
 	struct uclass *uc;
-	int count = 0;
 	int ret;
 
 	asynch_allowed = 1;
@@ -255,8 +254,7 @@ int usb_init(void)
 
 	uclass_foreach_dev(bus, uc) {
 		/* init low_level USB */
-		printf("USB%d:   ", count);
-		count++;
+		printf("Bus %s: ", bus->name);
 
 #ifdef CONFIG_SANDBOX
 		/*
@@ -327,10 +325,8 @@ int usb_init(void)
 	remove_inactive_children(uc, bus);
 

drivers/usb/host/usb-uclass.c int usb_init(void) · line 332

Quoted 10 lines
drivers/usb/host/usb-uclass.c +2 -4
 	/* if we were not able to find at least one working bus, bail out */
-	if (!count)
-		printf("No controllers found\n");
-	else if (controllers_initialized == 0)
-		printf("USB error: all controllers failed lowlevel init\n");
+	if (controllers_initialized == 0)
+		printf("No working controllers found\n");
 
 	return usb_started ? 0 : -1;
 }

Applied, thanks.

I wonder if this might break on non-DM/DT platforms though.

Signature · 2 lines
Best regards,
Marek Vasut