From: Wolfgang Denk Date: Sat, 09 May 2009 19:23:08 +0200 Subject: [U-Boot] [PATCH 2/3] console: unify printing current devices In-Reply-To: <1241863009-26036-2-git-send-email-plagnioj@jcrosoft.com> References: <1241863009-26036-1-git-send-email-plagnioj@jcrosoft.com> <1241863009-26036-2-git-send-email-plagnioj@jcrosoft.com> Message-ID: <20090509172308.0CD99832E416@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Jean-Christophe PLAGNIOL-VILLARD, In message <1241863009-26036-2-git-send-email-plagnioj@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 > --- > 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?