From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/4] usb: move scanned status into core
Date: Thu, 20 Jun 2013 16:05:23 +0200 [thread overview]
Message-ID: <1371737125-18820-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1371737125-18820-1-git-send-email-s.hauer@pengutronix.de>
A command should not be interested in the internal USB core state, so
move the state handling into the core.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/usb.c | 10 +++-------
drivers/usb/core/usb.c | 9 ++++++++-
include/usb/usb.h | 2 +-
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/commands/usb.c b/commands/usb.c
index e503065..9aee430 100644
--- a/commands/usb.c
+++ b/commands/usb.c
@@ -22,24 +22,20 @@
#include <usb/usb.h>
#include <getopt.h>
-static int scanned;
-
static int do_usb(int argc, char *argv[])
{
int opt;
+ int force = 0;
while ((opt = getopt(argc, argv, "f")) > 0) {
switch (opt) {
case 'f':
- scanned = 0;
+ force = 1;
break;
}
}
- if (!scanned) {
- usb_rescan();
- scanned = 1;
- }
+ usb_rescan(force);
return 0;
}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index e232111..07175dc 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -488,12 +488,19 @@ static struct usb_device *usb_alloc_new_device(void)
return usbdev;
}
-void usb_rescan(void)
+static int scanned;
+
+void usb_rescan(int force)
{
struct usb_device *dev, *tmp;
struct usb_host *host;
int ret;
+ if (scanned && !force)
+ return;
+
+ scanned = 1;
+
list_for_each_entry_safe(dev, tmp, &usb_device_list, list) {
list_del(&dev->list);
unregister_device(&dev->dev);
diff --git a/include/usb/usb.h b/include/usb/usb.h
index da0090e..2e1498c 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -248,7 +248,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);
+void usb_rescan(int force);
/* big endian -> little endian conversion */
/* some CPUs are already little endian e.g. the ARM920T */
--
1.8.3.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-06-20 14:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 14:05 [PATCH] usb: implement detect callback Sascha Hauer
2013-06-20 14:05 ` [PATCH 1/4] usb: rename USB devices to reflect bus structure Sascha Hauer
2013-06-20 14:05 ` Sascha Hauer [this message]
2013-06-20 14:05 ` [PATCH 3/4] usb: implement a usb_host_detect to scan individual USB hosts Sascha Hauer
2013-06-20 14:05 ` [PATCH 4/4] usb: ehci: implement detect callback 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=1371737125-18820-3-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@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