summaryrefslogtreecommitdiffstats
path: root/commands/detect.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-06-19 23:36:18 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-06-21 07:42:36 +0200
commitab058b10eb5deaf7ad00c6a2b7428aaec8d98473 (patch)
treefb85fe2cfe47b971e244ce75382ac3c35017535d /commands/detect.c
parent2d2ec6619b84fd70ceaa5f4a347c428ff24339ad (diff)
downloadbarebox-ab058b10eb5deaf7ad00c6a2b7428aaec8d98473.tar.gz
detect command: Add -a option to detect all devices
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/detect.c')
-rw-r--r--commands/detect.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/commands/detect.c b/commands/detect.c
index 0010a17..fbce4eb 100644
--- a/commands/detect.c
+++ b/commands/detect.c
@@ -28,8 +28,9 @@ static int do_detect(int argc, char *argv[])
int opt, i, ret;
int option_list = 0;
int option_error = 0;
+ int option_all = 0;
- while ((opt = getopt(argc, argv, "el")) > 0) {
+ while ((opt = getopt(argc, argv, "ela")) > 0) {
switch (opt) {
case 'l':
option_list = 1;
@@ -37,6 +38,11 @@ static int do_detect(int argc, char *argv[])
case 'e':
option_error = 1;
break;
+ case 'a':
+ option_all = 1;
+ break;
+ default:
+ return COMMAND_ERROR_USAGE;
}
}
@@ -48,6 +54,15 @@ static int do_detect(int argc, char *argv[])
return 0;
}
+ if (option_all) {
+ for_each_device(dev) {
+ ret = device_detect(dev);
+ if (ret && ret != -ENOSYS && option_error)
+ return ret;
+ }
+ return 0;
+ }
+
if (argc == optind)
return COMMAND_ERROR_USAGE;