summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-12-28 13:14:23 -0700
committerSimon Glass <sjg@chromium.org>2018-02-03 10:09:27 -0700
commit3707c6ee0d1f939130a62c945b56045d9a83fafc (patch)
tree86b7c70cf64113d77001fed0b2a57396aa3439a2 /common
parent8cb7c04248c9f0c3b79325b82844d79a680ef2eb (diff)
log: Add a way to log error-return values
When functions return an error it propagates up the stack to the point where it is reported. Often the error code provides enough information about the root cause of the error that this is obvious what went wrong. However in some cases the error may be hard to trace. For example if a driver uses several devices to perform an operation, it may not be obvious which one failed. Add a log_ret() macro to help with this. This can be used to wrap any error-return value. The logging system will then output a log record when the original error is generated, making it easy to trace the call stack of the error. This macro can significantly impact code size, so its use is controlled by a Kconfig option, which is enabled for sandbox. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig13
1 files changed, 13 insertions, 0 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 21e067c8582..dcab69d3215 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -504,6 +504,19 @@ config LOG_TEST
in various different ways to test that the logging system works
correctly with varoius settings.
+config LOG_ERROR_RETURN
+ bool "Log all functions which return an error"
+ depends on LOG
+ help
+ When an error is returned in U-Boot it is sometimes difficult to
+ figure out the root cause. For eaxmple, reading from SPI flash may
+ fail due to a problem in the SPI controller or due to the flash part
+ not returning the expected information. This option changes
+ log_ret() to log any errors it sees. With this option disabled,
+ log_ret() is a nop.
+
+ You can add log_ret() to all functions which return an error code.
+
endmenu
config DEFAULT_FDT_FILE