From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Wed, 27 Nov 2019 11:52:05 +0100 Subject: [U-Boot] [PATCH v1 2/4] dfu: Refactor do_dfu() to handle optional argument In-Reply-To: <20191113174344.33736-2-andriy.shevchenko@linux.intel.com> References: <20191113174344.33736-1-andriy.shevchenko@linux.intel.com> <20191113174344.33736-2-andriy.shevchenko@linux.intel.com> Message-ID: <20191127115205.2091813a@jawa> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, 13 Nov 2019 19:43:42 +0200 Andy Shevchenko wrote: > 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 > --- > cmd/dfu.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/cmd/dfu.c b/cmd/dfu.c > index 33491d0bc9..14a8ec879e 100644 > --- a/cmd/dfu.c > +++ b/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) 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); Acked-by: Lukasz Majewski Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: