mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-20 22:21:41 +00:00
Add pr_fmt() macro
This macro can be overridden in source files (before including common.h) and can be used to specify a prefix for debug and error messages. An example of how to use this is shown below: #define pr_fmt(fmt) "foo: " fmt #include <common.h> ... debug("bar"); The resulting message will read: foo: bar Acked-by: Simon Glass <sjg@chromium.org> Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
4efe52bf23
commit
be25d875b9
1 changed files with 9 additions and 5 deletions
|
@ -97,6 +97,10 @@ typedef volatile unsigned char vu_char;
|
||||||
#define _DEBUG 0
|
#define _DEBUG 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef pr_fmt
|
||||||
|
#define pr_fmt(fmt) fmt
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output a debug text when condition "cond" is met. The "cond" should be
|
* Output a debug text when condition "cond" is met. The "cond" should be
|
||||||
* computed by a preprocessor in the best case, allowing for the best
|
* computed by a preprocessor in the best case, allowing for the best
|
||||||
|
@ -105,7 +109,7 @@ typedef volatile unsigned char vu_char;
|
||||||
#define debug_cond(cond, fmt, args...) \
|
#define debug_cond(cond, fmt, args...) \
|
||||||
do { \
|
do { \
|
||||||
if (cond) \
|
if (cond) \
|
||||||
printf(fmt, ##args); \
|
printf(pr_fmt(fmt), ##args); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define debug(fmt, args...) \
|
#define debug(fmt, args...) \
|
||||||
|
@ -127,7 +131,7 @@ void __assert_fail(const char *assertion, const char *file, unsigned line,
|
||||||
__assert_fail(#x, __FILE__, __LINE__, __func__); })
|
__assert_fail(#x, __FILE__, __LINE__, __func__); })
|
||||||
|
|
||||||
#define error(fmt, args...) do { \
|
#define error(fmt, args...) do { \
|
||||||
printf("ERROR: " fmt "\nat %s:%d/%s()\n", \
|
printf("ERROR: " pr_fmt(fmt) "\nat %s:%d/%s()\n", \
|
||||||
##args, __FILE__, __LINE__, __func__); \
|
##args, __FILE__, __LINE__, __func__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue