From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Tue, 18 Sep 2012 13:25:34 -0500 Subject: [U-Boot] [PATCH 62/71] serial: spl: Implement empty functions for SPL In-Reply-To: <201209182003.17652.marex@denx.de> (from marex@denx.de on Tue Sep 18 13:03:17 2012) Message-ID: <1347992734.15284.9@snotra> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 09/18/2012 01:03:17 PM, Marek Vasut wrote: > Dear Scott Wood, > > > On 09/18/2012 12:13:57 PM, Marek Vasut wrote: > > > Dear Tom Rini, > > > > > > > On Mon, Sep 17, 2012 at 01:21:27AM +0200, Marek Vasut wrote: > > > > > Implement empty serial_* functions for SPL without serial > > > > > support enabled. This is imperative to haave once serial > > > > > multi is enabled unconditionally. > > > > > > > > > > Signed-off-by: Marek Vasut > > > > > Cc: Marek Vasut > > > > > Cc: Tom Rini > > > > > --- > > > > > > > > > > common/serial.c | 12 ++++++++++++ > > > > > 1 file changed, 12 insertions(+) > > > > > > > > > > diff --git a/common/serial.c b/common/serial.c > > > > > index 631af65..cef4ba8 100644 > > > > > --- a/common/serial.c > > > > > +++ b/common/serial.c > > > > > @@ -27,6 +27,16 @@ > > > > > > > > > > #include > > > > > #include > > > > > > > > > > +/* Implement prototypes for SPL without serial support */ > > > > > +#if defined(CONFIG_SPL_BUILD) && > > > > > > !defined(CONFIG_SPL_SERIAL_SUPPORT) > > > > > > > > +int serial_init(void) { return 0; } > > > > > +void serial_setbrg(void) {} > > > > > +int serial_getc(void) { return 0; } > > > > > +int serial_tstc(void) { return 0; } > > > > > +void serial_putc(const char c) {} > > > > > +void serial_puts(const char *s) {} > > > > > > > > This isn't quite right. We need to allow for: > > > > - No output SPL, strings collected (so #defined to do{} while > (0)) > > > > > > Which is not type-checked and will drag in bugs. > > > > Not all that likely, since most code will either be built with > printf > > enabled some of the time, or not contain printf (i.e. it's not quite > > the same situation as debug prints which may be rarely enabled). > > > > An inline function would be fine, but has to be done at the same > place > > that normal printf is declared -- whereas a macro could be done > after > > the fact. Unless you use a macro to redirect it to an inline > function > > of a different name... > > > > I do not understand why you want to put these stubs in a C file > instead > > of a header file, though -- you're preventing code from being > optimized > > away, which is important in some SPLs. > > I'd say the GCC must optimize it out anyway. I think I got some wires crossed and was thinking about printf/puts. We want those to be optimized away at compile time (not pointed to a stub at link time) on an SPL that has no output support, but once that's done the low level serial functions shouldn't be referenced anymore, right? -Scott