summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorRamon Fried <ramon.fried@gmail.com>2018-06-06 00:38:59 +0300
committerTom Rini <trini@konsulko.com>2018-06-07 17:08:06 -0400
commit948f32c8563568a76153f61ee4094c5aafe21eaf (patch)
tree2f3102dd6f8799333ac7877da30165985ad07476 /include/linux
parent46960ad6d09b948b5df5236029bc072f9800aeb3 (diff)
downloadu-boot-948f32c8563568a76153f61ee4094c5aafe21eaf.tar.gz
u-boot-948f32c8563568a76153f61ee4094c5aafe21eaf.tar.xz
u-boot-948f32c8563568a76153f61ee4094c5aafe21eaf.zip
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>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bug.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/bug.h b/include/linux/bug.h
index f07bb716fc..29f84168a3 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -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 */