[PATCH 7/9] usb: gadget: fastboot: beautify fb_run_command()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Only some refactoring, no functional change intended.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux