[PATCH] include: <asm-generic/bug.h>: implement WARN_ON_ONCE
Ahmad Fatoum
a.fatoum at pengutronix.de
Sun Jan 30 23:53:50 PST 2022
We have WARN_ON and WARN_ONCE. Add WARN_ON_ONCE as well to accommodate
Linux driver code using it.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/asm-generic/bug.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index f20e1b4d65ac..5d0a458eae74 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -50,4 +50,16 @@
} \
unlikely(__ret_warn_once); \
})
+
+#define WARN_ON_ONCE(condition) ({ \
+ static int __warned; \
+ int __ret_warn_once = !!(condition); \
+ \
+ if (unlikely(__ret_warn_once && !__warned)) { \
+ __warned = 1; \
+ __WARN(); \
+ } \
+ unlikely(__ret_warn_once); \
+})
+
#endif
--
2.30.2
More information about the barebox
mailing list