diff mbox

[U-Boot,2/4] thor:cmd: get the default command arguments from environment

Message ID 1402583107-29881-2-git-send-email-p.marczak@samsung.com
State Superseded
Delegated to: Marek Vasut
Headers show

Commit Message

Przemyslaw Marczak June 12, 2014, 2:25 p.m. UTC
This change adds support to getting the default DFU cmd line
arguments from the environment.

DFU and THOR uses the same command line arguments,
so the DFU command environment setup can be used also with THOR.

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
 common/cmd_thordown.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/common/cmd_thordown.c b/common/cmd_thordown.c
index 2dd7509..877b1be 100644
--- a/common/cmd_thordown.c
+++ b/common/cmd_thordown.c
@@ -15,17 +15,33 @@ 
 
 int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	if (argc < 4)
-		return CMD_RET_USAGE;
-
-	char *usb_controller = argv[1];
-	char *interface = argv[2];
-	char *devstring = argv[3];
-
+	char *usb_controller;
+	char *interface;
+	char *devstring;
 	int ret;
 
 	puts("TIZEN \"THOR\" Downloader\n");
 
+	switch (argc) {
+	case 1:
+		usb_controller = strdup(getenv("dfu_usb_con"));
+		interface = strdup(getenv("dfu_interface"));
+		devstring = strdup(getenv("dfu_device"));
+
+		if (!usb_controller || !interface || !devstring) {
+			puts("DFU: default device environment is not set.\n");
+			return CMD_RET_USAGE;
+		}
+		break;
+	case 4:
+		usb_controller = argv[1];
+		interface = argv[2];
+		devstring = argv[3];
+		break;
+	default:
+		return CMD_RET_USAGE;
+	}
+
 	ret = dfu_init_env_entities(interface, simple_strtoul(devstring,
 							      NULL, 10));
 	if (ret)