diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2019-11-27 18:12:14 +0200 |
---|---|---|
committer | Marek Vasut <marek.vasut+renesas@gmail.com> | 2020-01-07 14:37:50 +0100 |
commit | 2b1f8c2bdfe5f874233df221f037e1494bb8f875 (patch) | |
tree | b9bbc599ed539f5ca28926b91cf84439635442ec | |
parent | fdba54ea2f09b8c62007a3407f461aefb2e839f8 (diff) | |
download | u-boot-2b1f8c2bdfe5f874233df221f037e1494bb8f875.zip u-boot-2b1f8c2bdfe5f874233df221f037e1494bb8f875.tar.gz u-boot-2b1f8c2bdfe5f874233df221f037e1494bb8f875.tar.bz2 |
dfu: Refactor do_dfu() to handle optional argument
In the future we may utilize optional argument in 'dfu' command line.
As a preparation for this, refactor do_dfu().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Lukasz Majewski <lukma@denx.de>
-rw-r--r-- | cmd/dfu.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -30,22 +30,25 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP) char *interface = NULL; char *devstring = NULL; +#if defined(CONFIG_DFU_OVER_TFTP) + unsigned long value = 0; +#endif if (argc >= 4) { interface = argv[2]; devstring = argv[3]; } + +#if defined(CONFIG_DFU_OVER_TFTP) + if (argc == 5 || argc == 3) + value = simple_strtoul(argv[argc - 1], NULL, 0); +#endif #endif int ret = 0; #ifdef CONFIG_DFU_OVER_TFTP - unsigned long addr = 0; - if (!strcmp(argv[1], "tftp")) { - if (argc == 5 || argc == 3) - addr = simple_strtoul(argv[argc - 1], NULL, 0); - - return update_tftp(addr, interface, devstring); - } + if (!strcmp(argv[1], "tftp")) + return update_tftp(value, interface, devstring); #endif #ifdef CONFIG_DFU_OVER_USB ret = dfu_init_env_entities(interface, devstring); |