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>
This commit is contained in:
parent
fdba54ea2f
commit
2b1f8c2bdf
17
cmd/dfu.c
17
cmd/dfu.c
@ -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)
|
#if defined(CONFIG_DFU_OVER_USB) || defined(CONFIG_DFU_OVER_TFTP)
|
||||||
char *interface = NULL;
|
char *interface = NULL;
|
||||||
char *devstring = NULL;
|
char *devstring = NULL;
|
||||||
|
#if defined(CONFIG_DFU_OVER_TFTP)
|
||||||
|
unsigned long value = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (argc >= 4) {
|
if (argc >= 4) {
|
||||||
interface = argv[2];
|
interface = argv[2];
|
||||||
devstring = argv[3];
|
devstring = argv[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_DFU_OVER_TFTP)
|
||||||
|
if (argc == 5 || argc == 3)
|
||||||
|
value = simple_strtoul(argv[argc - 1], NULL, 0);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef CONFIG_DFU_OVER_TFTP
|
#ifdef CONFIG_DFU_OVER_TFTP
|
||||||
unsigned long addr = 0;
|
if (!strcmp(argv[1], "tftp"))
|
||||||
if (!strcmp(argv[1], "tftp")) {
|
return update_tftp(value, interface, devstring);
|
||||||
if (argc == 5 || argc == 3)
|
|
||||||
addr = simple_strtoul(argv[argc - 1], NULL, 0);
|
|
||||||
|
|
||||||
return update_tftp(addr, interface, devstring);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_DFU_OVER_USB
|
#ifdef CONFIG_DFU_OVER_USB
|
||||||
ret = dfu_init_env_entities(interface, devstring);
|
ret = dfu_init_env_entities(interface, devstring);
|
||||||
|
Loading…
Reference in New Issue
Block a user