thor:cmd: get the default command arguments from environment
authorPrzemyslaw Marczak <p.marczak@samsung.com>
Thu, 12 Jun 2014 08:20:59 +0000 (10:20 +0200)
committerLukasz Majewski <l.majewski@samsung.com>
Thu, 30 Oct 2014 12:16:49 +0000 (13:16 +0100)
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.

Change-Id: I2e0984c909147c13191f6d6646d094c9f02c392a
Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
common/cmd_thordown.c

index 76438e4ff9ab6abd8198b1785cfde74fc2d6103e..a5e6587cae8b5b3617131245a0c02ee119cbf939 100644 (file)
 
 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, devstring);
        if (ret)
                goto done;