Re: [U-Boot] [PATCH v4 6/9] Create a single cmd_call() function to handle command execution

2012-02-14 Thread Simon Glass
Hi Mike,

On Sat, Feb 4, 2012 at 7:22 PM, Mike Frysinger vap...@gentoo.org wrote:

 On Saturday 14 January 2012 01:45:54 Simon Glass wrote:
  --- a/common/command.c
  +++ b/common/command.c
 
  +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;
  +}

 does a static inline in the header produce the same code size or better ?


It doesn't really matter - this function becomes static in a later patch.
The common code is teased out of hush and main in two separate commits,
since otherwise it gets very confusing.



  --- a/include/command.h
  +++ b/include/command.h
 
  +#ifndef  __ASSEMBLY__
  +int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  +#endif   /* __ASSEMBLY__ */

 move the prototype up to the rest of the !ASSEMBLY code rather than
 putting it
 at the end by itself ?
 -mike


Will do.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 6/9] Create a single cmd_call() function to handle command execution

2012-02-04 Thread Mike Frysinger
On Saturday 14 January 2012 01:45:54 Simon Glass wrote:
 --- a/common/command.c
 +++ b/common/command.c

 +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;
 +}

does a static inline in the header produce the same code size or better ?

 --- a/include/command.h
 +++ b/include/command.h

 +#ifndef  __ASSEMBLY__
 +int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 +#endif   /* __ASSEMBLY__ */

move the prototype up to the rest of the !ASSEMBLY code rather than putting it 
at the end by itself ?
-mike


signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 6/9] Create a single cmd_call() function to handle command execution

2012-01-13 Thread Simon Glass
We should aim for a single point of entry to the commands, whichever
parser is used.

Signed-off-by: Simon Glass s...@chromium.org
---

 common/command.c  |   21 +
 common/hush.c |9 +++--
 common/main.c |3 +--
 include/command.h |5 +
 4 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/common/command.c b/common/command.c
index c5cecd3..d402e0f 100644
--- a/common/command.c
+++ b/common/command.c
@@ -487,3 +487,24 @@ 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 cmdtpPointer 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
+ * @return 0 if command succeeded, else non-zero
+ */
+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 e8e24d7..6cb921d 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -1679,13 +1679,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 f103ede..123dfa2 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1354,9 +1354,8 @@ static int builtin_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 3912b80..4316610 100644
--- a/include/command.h
+++ b/include/command.h
@@ -150,4 +150,9 @@ 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
+
+#ifndef__ASSEMBLY__
+int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+#endif /* __ASSEMBLY__ */
+
 #endif /* __COMMAND_H */
-- 
1.7.7.3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot