public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] cmd_time: merge run_command_and_time_it with cmd_process
Date: Mon, 03 Dec 2012 17:01:51 +0100	[thread overview]
Message-ID: <50BCCCEF.6040405@denx.de> (raw)
In-Reply-To: <1354548536-7567-1-git-send-email-richard.genoud@gmail.com>

On 12/03/2012 04:28 PM, Richard Genoud wrote:
> As far as every arch has a get_timer function,
> run_command_and_time_it code can now disappear.
> 
> Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
> ---
>  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(-)
> 
> diff --git a/common/cmd_time.c b/common/cmd_time.c
> index 6dbdbbf..9808cd6 100644
> --- a/common/cmd_time.c
> +++ b/common/cmd_time.c
> @@ -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;
> diff --git a/common/command.c b/common/command.c
> index 50c8429..a58dca6 100644
> --- a/common/command.c
> +++ b/common/command.c
> @@ -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);

Newline please:

		if (ticks)
			*ticks = get_timer(0);


>  		rc = cmd_call(cmdtp, flag, argc, argv);
> +		if (ticks) *ticks = get_timer(*ticks);

Here as well.

Thanks,
Stefan

  reply	other threads:[~2012-12-03 16:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-03 15:28 [U-Boot] [PATCH] cmd_time: merge run_command_and_time_it with cmd_process Richard Genoud
2012-12-03 16:01 ` Stefan Roese [this message]
2012-12-03 16:23   ` Richard Genoud
2012-12-03 21:32     ` Che-liang Chiou

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=50BCCCEF.6040405@denx.de \
    --to=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /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