[U-Boot] [PATCH 2/3] console: unify printing current devices

Wolfgang Denk wd at denx.de
Sat May 9 19:23:08 CEST 2009


Dear Jean-Christophe PLAGNIOL-VILLARD,

In message <1241863009-26036-2-git-send-email-plagnioj at jcrosoft.com> you wrote:
> actually the mpl's boards duplicate the printing current devices
> from common/console.c
> 
> create stdio_print_current_devices() for this purpose
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  board/mpl/common/common_util.c |   30 -----------------------
>  board/mpl/common/common_util.h |    1 -
>  board/mpl/mip405/mip405.c      |    3 +-
>  board/mpl/pip405/pip405.c      |    3 +-
>  board/mpl/vcma9/vcma9.c        |    3 +-
>  common/console.c               |   51 ++++++++++++++++++++++------------------
>  include/console.h              |    2 +
>  7 files changed, 36 insertions(+), 57 deletions(-)

Please split into 2 separate patches: one to factor out the code in
common/console.c, and another one to use this function to remove
dupolicated code.

...
> diff --git a/common/console.c b/common/console.c
> index 2add047..c1669d1 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -532,6 +532,33 @@ int console_init_f(void)
>  	return 0;
>  }
>  
> +void stdio_print_current_devices(void)
> +{
> +#ifdef CONFIG_SYS_CONSOLE_INFO_QUIET
> +	/* Print information */
> +	puts("In:    ");
> +	if (stdio_devices[stdin] == NULL) {
> +		puts("No input devices available!\n");
> +	} else {
> +		printf ("%s\n", stdio_devices[stdin]->name);
> +	}
> +
> +	puts("Out:   ");
> +	if (stdio_devices[stdout] == NULL) {
> +		puts("No output devices available!\n");
> +	} else {
> +		printf ("%s\n", stdio_devices[stdout]->name);
> +	}
> +
> +	puts("Err:   ");
> +	if (stdio_devices[stderr] == NULL) {
> +		puts("No error devices available!\n");
> +	} else {
> +		printf ("%s\n", stdio_devices[stderr]->name);
> +	}
> +#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
> +}
> +

Nearly the same code is repeated a second time for the
!CONFIG_SYS_CONSOLE_IS_IN_ENV case; if you factor out one into a
separate function, you should do the same for the other, too.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Is a computer language with goto's totally Wirth-less?


More information about the U-Boot mailing list