mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] usb: have usb_rescan return count of enumerated devices
Date: Thu, 29 Sep 2022 12:05:02 +0200	[thread overview]
Message-ID: <20220929100502.895553-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2022-09-29 10:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 10:05 Ahmad Fatoum [this message]
2022-10-04  7:48 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220929100502.895553-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox