From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Anderson Date: Fri, 27 Nov 2020 10:01:52 -0500 Subject: [PATCH v2 4/9] log: use console puts to output trace before LOG init In-Reply-To: <20201127112000.v2.4.I01167328d604e359d69c0d241754caeec1f65ebe@changeid> References: <20201127102100.11721-1-patrick.delaunay@st.com> <20201127112000.v2.4.I01167328d604e359d69c0d241754caeec1f65ebe@changeid> Message-ID: <07e2863f-aa2a-e995-1958-9bae28006a46@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 11/27/20 5:20 AM, Patrick Delaunay wrote: > Use the console puts functions to output the traces before > the log initialization (when CONFIG_LOG is not activated). > > This patch allows to display the first U-Boot traces > (with macro debug) when CONFIG_DEBUG_UART is activated > and not only drop them. > > For example for traces in board_f.c requested by the macro debug, > when LOG_DEBUG is defined and CONFIG_LOG is activated. > > Signed-off-by: Patrick Delaunay > --- > > Changes in v2: > - replace printascii by console puts, remove test on CONFIG_DEBUG_UART > > common/log.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/common/log.c b/common/log.c > index 212789d6b3..a4ed7d79f8 100644 > --- a/common/log.c > +++ b/common/log.c > @@ -246,6 +246,15 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file, > > if (!(gd->flags & GD_FLG_LOG_READY)) { > gd->log_drop_count++; > + > + /* display dropped traces with console puts and DEBUG_UART */ > + if (rec.level <= CONFIG_LOG_DEFAULT_LEVEL || rec.force_debug) { > + va_start(args, fmt); > + vsnprintf(buf, sizeof(buf), fmt, args); > + puts(buf); > + va_end(args); > + } > + > return -ENOSYS; > } > va_start(args, fmt); > Couldn't this be done like va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); rec.msg = buf; if (!gd || !(gd->flags & GD_FLG_LOG_READY)) { if (gd) gd->log_drop_count++; if (rec.level < CONFIG_LOG_DEFAULT_LEVEL || rec.force_debug) puts(buf); return -ENOSYS; } I don't see the optimization of not doing the vsnprintf() coming up very often. Also, shouldn't this return 0 instead of ENOSYS if something is actually printed? --Sean