public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 2/4] dfu: Refactor do_dfu() to handle optional argument
Date: Wed, 13 Nov 2019 19:43:42 +0200	[thread overview]
Message-ID: <20191113174344.33736-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20191113174344.33736-1-andriy.shevchenko@linux.intel.com>

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>
---
 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);
-- 
2.24.0

  reply	other threads:[~2019-11-13 17:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 17:43 [U-Boot] [PATCH v1 1/4] dfu: Drop unused prototype of dfu_trigger_reset() Andy Shevchenko
2019-11-13 17:43 ` Andy Shevchenko [this message]
2019-11-27 10:52   ` [U-Boot] [PATCH v1 2/4] dfu: Refactor do_dfu() to handle optional argument Lukasz Majewski
2019-11-13 17:43 ` [U-Boot] [PATCH v1 3/4] dfu: Add optional timeout parameter Andy Shevchenko
2019-11-27 10:56   ` Lukasz Majewski
2019-11-27 14:38     ` Andy Shevchenko
2019-11-27 15:09       ` Lukasz Majewski
2019-11-13 17:43 ` [U-Boot] [PATCH v1 4/4] x86: edison: Enable DFU timeout Andy Shevchenko
2019-11-27 10:57   ` Lukasz Majewski
2019-11-27 15:21     ` Andy Shevchenko
2019-11-27 15:37       ` Andy Shevchenko
2019-11-27 16:10       ` Lukasz Majewski
2019-11-27 16:45         ` Andy Shevchenko
2019-11-27 17:11           ` Lukasz Majewski
2019-11-27 10:51 ` [U-Boot] [PATCH v1 1/4] dfu: Drop unused prototype of dfu_trigger_reset() Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191113174344.33736-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox