summaryrefslogtreecommitdiffstats
path: root/common/log.c
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@st.com>2020-11-27 11:20:52 +0100
committerTom Rini <trini@konsulko.com>2021-01-15 14:36:11 -0500
commitf0e90e0eadbed59f0afb0d281816873339fd51ee (patch)
tree196bacce6a26c6addf3ff38271c40ff762132dc6 /common/log.c
parent6278ec1919fff83a4f0adde1e5d987852b154ebf (diff)
downloadu-boot-f0e90e0eadbed59f0afb0d281816873339fd51ee.tar.gz
u-boot-f0e90e0eadbed59f0afb0d281816873339fd51ee.tar.xz
u-boot-f0e90e0eadbed59f0afb0d281816873339fd51ee.zip
log: don't build the trace buffer when log is not ready
Update _log function to drop any traces when log is yet initialized: vsnprintf is no more executed in this case. This patch allows to reduce the cost for the dropped early debug trace. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Diffstat (limited to 'common/log.c')
-rw-r--r--common/log.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/common/log.c b/common/log.c
index ce39918e04..212789d6b3 100644
--- a/common/log.c
+++ b/common/log.c
@@ -228,6 +228,9 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
struct log_rec rec;
va_list args;
+ if (!gd)
+ return -ENOSYS;
+
/* Check for message continuation */
if (cat == LOGC_CONT)
cat = gd->logc_prev;
@@ -240,15 +243,15 @@ int _log(enum log_category_t cat, enum log_level_t level, const char *file,
rec.file = file;
rec.line = line;
rec.func = func;
+
+ if (!(gd->flags & GD_FLG_LOG_READY)) {
+ gd->log_drop_count++;
+ return -ENOSYS;
+ }
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++;
- return -ENOSYS;
- }
if (!log_dispatch(&rec)) {
gd->logc_prev = cat;
gd->logl_prev = level;