From: Simon Glass <sjg@chromium.org>
Date: Sun, 30 Jul 2023 17:15:12 +0000 (-0600)
Subject: usb: Return -ENOENT when no devices are found
X-Git-Tag: v2025.01-rc5-pxa1908~891^2~35
X-Git-Url: http://git.dujemihanovic.xyz/%22http:/www.sics.se/static/%7B%7B%20%24.Site.BaseURL%20%7D%7Dposts/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=4c4ccc5a0499cf2abdca95415caf7443c760a26d;p=u-boot.git

usb: Return -ENOENT when no devices are found

When USB finds no devices it currently returns -EPERM which bootstd does
not understand. This causes other bootdevs of the same priority to be
skipped.

Fix this by returning the correct error code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 02c0138a20..7a03435ba7 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -346,7 +346,7 @@ int usb_init(void)
 	if (controllers_initialized == 0)
 		printf("No working controllers found\n");
 
-	return usb_started ? 0 : -1;
+	return usb_started ? 0 : -ENOENT;
 }
 
 int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
diff --git a/include/usb.h b/include/usb.h
index 42b001c3dd..09e3f0cb30 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -257,7 +257,14 @@ int usb_kbd_deregister(int force);
 
 #endif
 /* routines */
-int usb_init(void); /* initialize the USB Controller */
+
+/*
+ * usb_init() - initialize the USB Controllers
+ *
+ * Returns: 0 if OK, -ENOENT if there are no USB devices
+ */
+int usb_init(void);
+
 int usb_stop(void); /* stop the USB Controller */
 int usb_detect_change(void); /* detect if a USB device has been (un)plugged */