summaryrefslogtreecommitdiffstats
path: root/commands/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands/usb.c')
-rw-r--r--commands/usb.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/commands/usb.c b/commands/usb.c
index 6605e031a7..e28afd051b 100644
--- a/commands/usb.c
+++ b/commands/usb.c
@@ -22,17 +22,35 @@
#include <common.h>
#include <command.h>
#include <usb/usb.h>
+#include <getopt.h>
+
+static int scanned;
static int do_usb(int argc, char *argv[])
{
- usb_rescan();
+ int opt;
+
+ while ((opt = getopt(argc, argv, "f")) > 0) {
+ switch (opt) {
+ case 'f':
+ scanned = 0;
+ break;
+ }
+ }
+
+ if (!scanned) {
+ usb_rescan();
+ scanned = 1;
+ }
return 0;
}
-static const __maybe_unused char cmd_usb_help[] =
-"Usage: usb\n"
-"(re-)detect USB devices\n";
+BAREBOX_CMD_HELP_START(usb)
+BAREBOX_CMD_HELP_USAGE("usb [-f]\n")
+BAREBOX_CMD_HELP_SHORT("Scan for USB devices.\n")
+BAREBOX_CMD_HELP_OPT("-f", "force. Rescan if if if have scanned once\n")
+BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(usb)
.cmd = do_usb,