mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 7/9] usb: gadget: fastboot: beautify fb_run_command()
Date: Fri,  9 Feb 2018 10:43:14 +0100	[thread overview]
Message-ID: <20180209094316.8523-8-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180209094316.8523-1-s.hauer@pengutronix.de>

Only some refactoring, no functional change intended.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/f_fastboot.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index e474543e2c..d349227f08 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -1017,24 +1017,25 @@ struct cmd_dispatch_info {
 	void (*cb)(struct f_fastboot *f_fb, const char *opt);
 };
 
-static void fb_run_command(struct f_fastboot *f_fb, const char *cmd,
+static void fb_run_command(struct f_fastboot *f_fb, const char *cmdbuf,
 		const struct cmd_dispatch_info *cmds, int num_commands)
 {
-	void (*func_cb)(struct f_fastboot *f_fb, const char *cmd) = NULL;
+	const struct cmd_dispatch_info *cmd;
 	int i;
 
 	console_countdown_abort();
 
 	for (i = 0; i < num_commands; i++) {
-		if (!strcmp_l1(cmds[i].cmd, cmd)) {
-			func_cb = cmds[i].cb;
-			cmd += strlen(cmds[i].cmd);
-			func_cb(f_fb, cmd);
+		cmd = &cmds[i];
+
+		if (!strcmp_l1(cmd->cmd, cmdbuf)) {
+			cmd->cb(f_fb, cmdbuf + strlen(cmd->cmd));
+
 			return;
 		}
 	}
 
-	fastboot_tx_print(f_fb, "FAILunknown command %s", cmd);
+	fastboot_tx_print(f_fb, "FAILunknown command %s", cmdbuf);
 }
 
 static void cb_oem_getenv(struct f_fastboot *f_fb, const char *cmd)
-- 
2.15.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-02-09  9:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09  9:43 [PATCH 0/9] Fastboot customization support Sascha Hauer
2018-02-09  9:43 ` [PATCH 1/9] ubiformat: Allow to ubiformat with a buffer given Sascha Hauer
2018-02-09  9:43 ` [PATCH 2/9] usb: gadget: fastboot: Make sparse support optional Sascha Hauer
2018-02-09  9:43 ` [PATCH 3/9] usb: gadget: fastboot: pass struct f_fastboot * around Sascha Hauer
2018-02-09  9:43 ` [PATCH 4/9] usb: gadget: fastboot: use read_file_2 Sascha Hauer
2018-02-09  9:43 ` [PATCH 5/9] usb: gadget: fastboot: Always remove temporary file Sascha Hauer
2018-02-09  9:43 ` [PATCH 6/9] usb: gadget: fastboot: fix typo Sascha Hauer
2018-02-09  9:43 ` Sascha Hauer [this message]
2018-02-09  9:43 ` [PATCH 8/9] usb: gadget: fastboot: Add option to download to a buffer Sascha Hauer
2018-02-09  9:43 ` [PATCH 9/9] usb: gadget: fastboot: Add external command execution support Sascha Hauer

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=20180209094316.8523-8-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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