once: implement DO_ONCE_LITE for non-fast-path "do once" functionality
[sfrench/cifs-2.6.git] / include / asm-generic / bug.h
index b402494883b682e8d0fdea0a702a37ee93078632..bafc51f483c49ab808e5c2dc75ee148c8d405e4f 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/compiler.h>
 #include <linux/instrumentation.h>
+#include <linux/once_lite.h>
 
 #define CUT_HERE               "------------[ cut here ]------------\n"
 
@@ -140,39 +141,15 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 })
 
 #ifndef WARN_ON_ONCE
-#define WARN_ON_ONCE(condition)        ({                              \
-       static bool __section(".data.once") __warned;           \
-       int __ret_warn_once = !!(condition);                    \
-                                                               \
-       if (unlikely(__ret_warn_once && !__warned)) {           \
-               __warned = true;                                \
-               WARN_ON(1);                                     \
-       }                                                       \
-       unlikely(__ret_warn_once);                              \
-})
+#define WARN_ON_ONCE(condition)                                        \
+       DO_ONCE_LITE_IF(condition, WARN_ON, 1)
 #endif
 
-#define WARN_ONCE(condition, format...)        ({                      \
-       static bool __section(".data.once") __warned;           \
-       int __ret_warn_once = !!(condition);                    \
-                                                               \
-       if (unlikely(__ret_warn_once && !__warned)) {           \
-               __warned = true;                                \
-               WARN(1, format);                                \
-       }                                                       \
-       unlikely(__ret_warn_once);                              \
-})
+#define WARN_ONCE(condition, format...)                                \
+       DO_ONCE_LITE_IF(condition, WARN, 1, format)
 
-#define WARN_TAINT_ONCE(condition, taint, format...)   ({      \
-       static bool __section(".data.once") __warned;           \
-       int __ret_warn_once = !!(condition);                    \
-                                                               \
-       if (unlikely(__ret_warn_once && !__warned)) {           \
-               __warned = true;                                \
-               WARN_TAINT(1, taint, format);                   \
-       }                                                       \
-       unlikely(__ret_warn_once);                              \
-})
+#define WARN_TAINT_ONCE(condition, taint, format...)           \
+       DO_ONCE_LITE_IF(condition, WARN_TAINT, 1, taint, format)
 
 #else /* !CONFIG_BUG */
 #ifndef HAVE_ARCH_BUG