summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2017-03-24 11:21:23 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 07:47:28 +0200
commit462f2af3a08f71223e78b5d406dd1a1ba02dd113 (patch)
treef2497abdfa5b2275e9b90de1f42ce164b63fa8e1 /commands
parent09433f971e92b946ec44526fee84487514a59192 (diff)
downloadbarebox-462f2af3a08f71223e78b5d406dd1a1ba02dd113.tar.gz
barebox-462f2af3a08f71223e78b5d406dd1a1ba02dd113.tar.xz
commands: usbgadget: provide fallback to global variables
usbgadget autostarter is providing now a global variable to configure fastboot. We can use is as fallback for the cmd_usbgadget as well. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/usbgadget.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/commands/usbgadget.c b/commands/usbgadget.c
index 314884aee8..02c2c96b02 100644
--- a/commands/usbgadget.c
+++ b/commands/usbgadget.c
@@ -20,6 +20,7 @@
*/
#include <common.h>
#include <command.h>
+#include <environment.h>
#include <errno.h>
#include <malloc.h>
#include <getopt.h>
@@ -32,11 +33,11 @@
static int do_usbgadget(int argc, char *argv[])
{
int opt, ret;
- int acm = 1, create_serial = 0;
- char *fastboot_opts = NULL, *dfu_opts = NULL;
+ int acm = 1, create_serial = 0, fastboot_set = 0;
+ const char *fastboot_opts = NULL, *dfu_opts = NULL;
struct f_multi_opts *opts;
- while ((opt = getopt(argc, argv, "asdA:D:")) > 0) {
+ while ((opt = getopt(argc, argv, "asdA::D:")) > 0) {
switch (opt) {
case 'a':
acm = 1;
@@ -51,6 +52,7 @@ static int do_usbgadget(int argc, char *argv[])
break;
case 'A':
fastboot_opts = optarg;
+ fastboot_set = 1;
break;
case 'd':
usb_multi_unregister();
@@ -60,6 +62,9 @@ static int do_usbgadget(int argc, char *argv[])
}
}
+ if (fastboot_set && !fastboot_opts)
+ fastboot_opts = getenv("global.usbgadget.fastboot_function");
+
if (!dfu_opts && !fastboot_opts && !create_serial)
return COMMAND_ERROR_USAGE;