public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] Create a single cmd_call() function to handle command execution
@ 2011-10-25  3:52 Simon Glass
  2011-10-25  3:52 ` [U-Boot] [PATCH 2/2] RFC: Add XON/XOFF support Simon Glass
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Simon Glass @ 2011-10-25  3:52 UTC (permalink / raw)
  To: u-boot

We should aim for a single point of entry to the commands, whichever
parser is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 common/command.c  |   10 ++++++++++
 common/hush.c     |    9 +++------
 common/main.c     |    3 +--
 include/command.h |   12 ++++++++++++
 4 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/common/command.c b/common/command.c
index c5cecd3..acc1c15 100644
--- a/common/command.c
+++ b/common/command.c
@@ -487,3 +487,13 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)
 	}
 }
 #endif
+
+int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	int result;
+
+	result = (cmdtp->cmd)(cmdtp, flag, argc, argv);
+	if (result)
+		debug("Command failed, result=%d", result);
+	return result;
+}
diff --git a/common/hush.c b/common/hush.c
index 940889b..8106a91 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -1695,13 +1695,10 @@ static int run_pipe_real(struct pipe *pi)
 				rcode = x->function(child);
 #else
 				/* OK - call function to do the command */
-
-				rcode = (cmdtp->cmd)
-(cmdtp, flag,child->argc-i,&child->argv[i]);
-				if ( !cmdtp->repeatable )
+				rcode = cmd_call(cmdtp, flag,  child->argc-i,
+						 &child->argv[i]);
+				if (!cmdtp->repeatable)
 					flag_repeat = 0;
-
-
 #endif
 				child->argv-=i;  /* XXX restore hack so free() can work right */
 #ifndef __U_BOOT__
diff --git a/common/main.c b/common/main.c
index e96c95a..3b60d27 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1376,9 +1376,8 @@ int run_command (const char *cmd, int flag)
 #endif
 
 		/* OK - call function to do the command */
-		if ((cmdtp->cmd) (cmdtp, flag, argc, argv) != 0) {
+		if (cmd_call(cmdtp, flag, argc, argv) != 0)
 			rc = -1;
-		}
 
 		repeatable &= cmdtp->repeatable;
 
diff --git a/include/command.h b/include/command.h
index c270110..3eeef7c 100644
--- a/include/command.h
+++ b/include/command.h
@@ -147,4 +147,16 @@ extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
 #endif
+
+/**
+ * Call a command function. This should be the only route in U-Boot to call
+ * a command, so that we can track whether we are waiting for input or
+ * executing a command.
+ *
+ * @param cmdtp		Pointer to the command to execute
+ * @param flag		Some flags normally 0 (see CMD_FLAG_.. above)
+ * @param argc		Number of arguments (arg 0 must be the command text)
+ * @param argv		Arguments
+ */
+int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 #endif	/* __COMMAND_H */
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-10-30 23:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-25  3:52 [U-Boot] [PATCH 1/2] Create a single cmd_call() function to handle command execution Simon Glass
2011-10-25  3:52 ` [U-Boot] [PATCH 2/2] RFC: Add XON/XOFF support Simon Glass
2011-10-25  8:09   ` Graeme Russ
2011-10-25 23:56     ` Simon Glass
2011-10-30 21:30   ` Mike Frysinger
2011-10-30 23:53   ` Albert ARIBAUD
2011-10-25  7:46 ` [U-Boot] [PATCH 1/2] Create a single cmd_call() function to handle command execution Wolfgang Denk
2011-10-25  8:03   ` Graeme Russ
2011-10-25 13:33     ` Simon Glass
2011-10-25 18:20     ` Wolfgang Denk
2011-10-25 13:57 ` Mike Frysinger
2011-10-25 23:05   ` Simon Glass
2011-10-30 21:28     ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox