mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] usb: have usb_rescan return count of enumerated devices
@ 2022-09-29 10:05 Ahmad Fatoum
  2022-10-04  7:48 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-09-29 10:05 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Some USB mass storage devices can take a comparatively long time after
vbus is applied until they can be enumerated. Board code can reissue
usb_rescan() to retry enumeration at a later time. It's useful for
board code to check whether any new devices have been detected by a
usb_rescan() call. To facilitate this, have usb_rescan() return the
number of devices found in addition to printing it to the log.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/usb/core/usb.c | 4 +++-
 include/usb/usb.h      | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 34a0f004f7bb..ed3a96cb9e5e 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -599,7 +599,7 @@ int usb_host_detect(struct usb_host *host)
 	return 0;
 }
 
-void usb_rescan(void)
+int usb_rescan(void)
 {
 	struct usb_host *host;
 	int ret;
@@ -613,6 +613,8 @@ void usb_rescan(void)
 	}
 
 	pr_info("%d USB Device(s) found\n", dev_count);
+
+	return dev_count;
 }
 
 /*-------------------------------------------------------------------
diff --git a/include/usb/usb.h b/include/usb/usb.h
index 39f475091617..04b433ba73ca 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -201,7 +201,7 @@ int usb_clear_halt(struct usb_device *dev, int pipe);
 int usb_string(struct usb_device *dev, int index, char *buf, size_t size);
 int usb_set_interface(struct usb_device *dev, int interface, int alternate);
 
-void usb_rescan(void);
+int usb_rescan(void);
 
 /* big endian -> little endian conversion */
 /* some CPUs are already little endian e.g. the ARM920T */
-- 
2.30.2




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-04  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 10:05 [PATCH] usb: have usb_rescan return count of enumerated devices Ahmad Fatoum
2022-10-04  7:48 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox