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
CONFIG_PRE_CON_BUF_ADDR=0x100000
CONFIG_LOG=y
CONFIG_LOG_MAX_LEVEL=6
+CONFIG_LOG_ERROR_RETURN=y
CONFIG_CMD_CPU=y
CONFIG_CMD_LICENSE=y
CONFIG_CMD_BOOTZ=y
as the category, so you should #define this right at the top of the source
file to ensure the category is correct.
+You can also define CONFIG_LOG_ERROR_RETURN to enable the log_ret() macro. This
+can be used whenever your function returns an error value:
+
+ return log_ret(uclass_first_device(UCLASS_MMC, &dev));
+
+This will write a log record when an error code is detected (a value < 0). This
+can make it easier to trace errors that are generated deep in the call stack.
+
Code size
---------
({ if (!(x) && _DEBUG) \
__assert_fail(#x, __FILE__, __LINE__, __func__); })
+#ifdef CONFIG_LOG_ERROR_RETURN
+#define log_ret(_ret) ({ \
+ int __ret = (_ret); \
+ if (__ret < 0) \
+ log(LOG_CATEGORY, LOGL_ERR, "returning err=%d\n", __ret); \
+ __ret; \
+ })
+#else
+#define log_ret(_ret) (_ret)
+#endif
+
/**
* struct log_rec - a single log record
*