mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
bug.h: introduce WARN_ONCE
Add WARN_ONCE definition to allow single time notification of warnings to the user. Taken from Linux kernel (4.17) with slight changes (Removed __section(.data.once)) Signed-off-by: Ramon Fried <ramon.fried@gmail.com> [trini: Drop the musb and dwc3 compat versions] Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
46960ad6d0
commit
948f32c856
3 changed files with 18 additions and 7 deletions
|
@ -20,6 +20,13 @@
|
|||
unlikely(__ret_warn_on); \
|
||||
})
|
||||
|
||||
#define WARN(condition, format...) ({ \
|
||||
int __ret_warn_on = !!(condition); \
|
||||
if (unlikely(__ret_warn_on)) \
|
||||
printf(format); \
|
||||
unlikely(__ret_warn_on); \
|
||||
})
|
||||
|
||||
#define WARN_ON_ONCE(condition) ({ \
|
||||
static bool __warned; \
|
||||
int __ret_warn_once = !!(condition); \
|
||||
|
@ -31,4 +38,15 @@
|
|||
unlikely(__ret_warn_once); \
|
||||
})
|
||||
|
||||
#define WARN_ONCE(condition, format...) ({ \
|
||||
static bool __warned; \
|
||||
int __ret_warn_once = !!(condition); \
|
||||
\
|
||||
if (unlikely(__ret_warn_once && !__warned)) { \
|
||||
__warned = true; \
|
||||
WARN(1, format); \
|
||||
} \
|
||||
unlikely(__ret_warn_once); \
|
||||
})
|
||||
|
||||
#endif /* _LINUX_BUG_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue