mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [RFC PATCH 2/2] commands: usbgadget: provide fall back to global variables
Date: Fri, 24 Mar 2017 10:07:25 +0100	[thread overview]
Message-ID: <20170324090725.22192-2-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20170324090725.22192-1-o.rempel@pengutronix.de>

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>
---
 commands/usbgadget.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/commands/usbgadget.c b/commands/usbgadget.c
index a7e8d6c0c..9f250633d 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;
-	int acm = 1, create_serial = 0;
+	int acm = 1, create_serial = 0, fastboot_set = 0;
 	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;
 
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2017-03-24  9:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24  9:07 [RFC PATCH 1/2] usb: gadget: start usbgadget automatically Oleksij Rempel
2017-03-24  9:07 ` Oleksij Rempel [this message]
2017-03-24 10:19 ` Oleksij Rempel

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=20170324090725.22192-2-o.rempel@pengutronix.de \
    --to=o.rempel@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