cmd_time: merge run_command_and_time_it with cmd_process
PATCH 1/1 cmd_time: merge run_command_and_time_it with cmd_process
As far as every arch has a get_timer function,run_command_and_time_it code can now disappear.
--- common/cmd_time.c | 33 ++------------------------------- common/command.c | 4 +++- common/hush.c | 2 +- common/main.c | 2 +- include/command.h | 4 +++- 5 files changed, 10 insertions(+), 35 deletions(-)
common/cmd_time.c +2 -31
@@ -22,36 +22,6 @@#include <common.h> #include <command.h> -/* -* TODO(clchiou): This function actually minics the bottom-half of the -* run_command() function. Since this function has ARM-dependent timer -* codes, we cannot merge it with the run_command() for now. -*/ -static int run_command_and_time_it (int flag,int argc,char *const argv[], -ulong *cycles) -{ -cmd_tbl_t *cmdtp =find_cmd (argv[0 ]); -int retval =0 ; - -if (!cmdtp) { -printf ("%s: command not found\n" , argv[0 ]); -return 1 ; - } -if (argc > cmdtp->maxargs) -return CMD_RET_USAGE ; - -/* -* TODO(clchiou): get_timer_masked() is only defined in certain ARM -* boards. We could use the new timer API that Graeme is proposing -* so that this piece of code would be arch-independent. -*/ - *cycles =get_timer_masked (); - retval = cmdtp->cmd (cmdtp, flag, argc, argv); - *cycles =get_timer_masked () - *cycles; - -return retval; -} -static void report_time (ulong cycles) {ulong minutes, seconds, milliseconds;
@@ -75,11 +45,12 @@ static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {ulong cycles =0 ;int retval =0 ; +int repeatable;if (argc ==1 )return CMD_RET_USAGE ; - retval =run_command_and_time_it (0 , argc -1 , argv +1 , &cycles); + retval =cmd_process (0 , argc -1 , argv +1 , &repeatable, &cycles);report_time (cycles);return retval;
common/command.c +3 -1
@@ -513,7 +513,7 @@ static int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }enum command_ret_t cmd_process (int flag,int argc,char *const argv[], -int *repeatable) +int *repeatable,ulong *ticks) {enum command_ret_t rc =CMD_RET_SUCCESS ;cmd_tbl_t *cmdtp;
@@ -543,7 +543,9 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[],/* If OK so far, then do the command */ if (!rc) { +if (ticks) *ticks =get_timer (0 ); rc =cmd_call (cmdtp, flag, argc, argv); +if (ticks) *ticks =get_timer (*ticks); *repeatable &= cmdtp->repeatable; }if (rc ==CMD_RET_USAGE )
common/hush.c +1 -1
@@ -1665,7 +1665,7 @@ static int run_pipe_real(struct pipe *pi) }/* Process the command */ return cmd_process (flag, child->argc, child->argv, - &flag_repeat); + &flag_repeat,NULL );#endif }#ifndef __U_BOOT__
common/main.c +1 -1
@@ -1442,7 +1442,7 @@ static int builtin_run_command(const char *cmd, int flag)continue ; } -if (cmd_process (flag, argc, argv, &repeatable)) +if (cmd_process (flag, argc, argv, &repeatable,NULL )) rc =-1 ;/* Did the user stop this? */
include/command.h +3 -1
@@ -139,10 +139,12 @@ enum command_ret_t {* @param repeatable This function sets this to 0 if the command is not * repeatable. If the command is repeatable, the value * is left unchanged. +* @param ticks If ticks is not null, this function set it to the +* number of ticks the command took to complete. * @return 0 if the command succeeded, 1 if it failed */ int cmd_process (int flag,int argc,char *const argv[], -int *repeatable); +int *repeatable,ulong *ticks);#endif /* __ASSEMBLY__ */
Signature · 1 line
1.7.2.5
PATCH 1/1 cmd_time: merge run_command_and_time_it with cmd_process
Quoted 81 lines · Richard Genoud
As far as every arch has a
get_timerfunction,run_command_and_time_itcode can now disappear.Signed-off-by Richard Genoud <[email protected]>--- common/cmd_time.c | 33 ++------------------------------- common/command.c | 4 +++- common/hush.c | 2 +- common/main.c | 2 +- include/command.h | 4 +++- 5 files changed, 10 insertions(+), 35 deletions(-)common/cmd_time.c +2
-31@@ -22,36 +22,6 @@#include <common.h> #include <command.h> -/* -* TODO(clchiou): This function actually minics the bottom-half of the -* run_command() function. Since this function has ARM-dependent timer -* codes, we cannot merge it with the run_command() for now. -*/ -static int run_command_and_time_it (int flag,int argc,char *const argv[], -ulong *cycles) -{ -cmd_tbl_t *cmdtp =find_cmd (argv[0 ]); -int retval =0 ; - -if (!cmdtp) { -printf ("%s: command not found\n" , argv[0 ]); -return 1 ; - } -if (argc > cmdtp->maxargs) -return CMD_RET_USAGE ; - -/* -* TODO(clchiou): get_timer_masked() is only defined in certain ARM -* boards. We could use the new timer API that Graeme is proposing -* so that this piece of code would be arch-independent. -*/ - *cycles =get_timer_masked (); - retval = cmdtp->cmd (cmdtp, flag, argc, argv); - *cycles =get_timer_masked () - *cycles; - -return retval; -} -static void report_time (ulong cycles) {ulong minutes, seconds, milliseconds;@@ -75,11 +45,12 @@ static int do_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {ulong cycles =0 ;int retval =0 ; +int repeatable;if (argc ==1 )return CMD_RET_USAGE ; - retval =run_command_and_time_it (0 , argc -1 , argv +1 , &cycles); + retval =cmd_process (0 , argc -1 , argv +1 , &repeatable, &cycles);report_time (cycles);return retval;common/command.c +1
-1@@ -513,7 +513,7 @@ static int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }enum command_ret_t cmd_process (int flag,int argc,char *const argv[], -int *repeatable) +int *repeatable,ulong *ticks) {enum command_ret_t rc =CMD_RET_SUCCESS ;cmd_tbl_t *cmdtp;
common/command.c enum command_ret_t cmd_process(int flag, int argc, char * const argv[], · line 546
Quoted 4 lines
common/command.c +1
-0@@ -543,7 +543,9 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[],/* If OK so far, then do the command */ if (!rc) { +if (ticks) *ticks =get_timer (0 );
Newline please:
if (ticks) *ticks = get_timer(0);
common/command.c enum command_ret_t cmd_process(int flag, int argc, char * const argv[], · line 548
Quoted 2 lines
common/command.c +1
-0rc =cmd_call (cmdtp, flag, argc, argv); +if (ticks) *ticks =get_timer (*ticks);
Here as well.
Thanks,
Stefan
PATCH 1/1 cmd_time: merge run_command_and_time_it with cmd_process
2012/12/3 Stefan Roese <[email protected]>:
Quoted 12 lines
common/command.c enum command_ret_t cmd_process(int flag, int argc, char * const argv[], · line 546
Quoted 5 lines
common/command.c +1
-0@@ -543,7 +543,9 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[],/* If OK so far, then do the command */ if (!rc) { +if (ticks) *ticks =get_timer (0 );Newline please:
if (ticks) *ticks = get_timer(0);
Quoted 8 lines
common/command.c enum command_ret_t cmd_process(int flag, int argc, char * const argv[], · line 548
Quoted 2 lines
common/command.c +1
-0rc =cmd_call (cmdtp, flag, argc, argv); +if (ticks) *ticks =get_timer (*ticks);Here as well.
Thanks,
Stefan
Ok, I'll resend it with new lines (I thought it was a little bit more readable without new lines).
Thanks !
Richard.
PATCH 1/1 cmd_time: merge run_command_and_time_it with cmd_process
Quoted 30 lines · Richard Genoud
2012/12/3 Stefan Roese <[email protected]>:
Quoted 12 lines
common/command.c enum command_ret_t cmd_process(int flag, int argc, char * const argv[], · line 546
Quoted 5 lines
common/command.c +1
-0@@ -543,7 +543,9 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[],/* If OK so far, then do the command */ if (!rc) { +if (ticks) *ticks =get_timer (0 );Newline please:
if (ticks) *ticks = get_timer(0);Quoted 8 lines
common/command.c enum command_ret_t cmd_process(int flag, int argc, char * const argv[], · line 548
Quoted 2 lines
common/command.c +1
-0rc =cmd_call (cmdtp, flag, argc, argv); +if (ticks) *ticks =get_timer (*ticks);Here as well.
Thanks,
StefanOk, I'll resend it with new lines (I thought it was a little bit more readable without new lines).
Thanks !Richard.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot