]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bug: Allow architectures to provide __WARN_printf()
authorPeter Zijlstra <peterz@infradead.org>
Mon, 2 Jun 2025 13:08:36 +0000 (15:08 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 21 Nov 2025 10:21:32 +0000 (11:21 +0100)
In addition to providing __WARN_FLAGS(), allow an architecture to also
provide __WARN_printf().

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251110115757.807154591@infradead.org
include/asm-generic/bug.h

index 4bfbeae30c4285e8fe6873f6c21737181052a799..21d2c8f88d498c4e7250e2d51c41cf262c741a1e 100644 (file)
@@ -100,23 +100,9 @@ void warn_slowpath_fmt(const char *file, const int line, unsigned taint,
                       const char *fmt, ...);
 extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
 
-#ifndef __WARN_FLAGS
-#define __WARN()               __WARN_printf(TAINT_WARN, NULL)
-#define __WARN_printf(taint, arg...) do {                              \
-               instrumentation_begin();                                \
-               warn_slowpath_fmt(__FILE__, __LINE__, taint, arg);      \
-               instrumentation_end();                                  \
-       } while (0)
-#else
+#ifdef __WARN_FLAGS
 #define __WARN()               __WARN_FLAGS("", BUGFLAG_TAINT(TAINT_WARN))
 
-#define __WARN_printf(taint, arg...) do {                              \
-               instrumentation_begin();                                \
-               __warn_printk(arg);                                     \
-               __WARN_FLAGS("", BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\
-               instrumentation_end();                                  \
-       } while (0)
-
 #ifndef WARN_ON
 #define WARN_ON(condition) ({                                          \
        int __ret_warn_on = !!(condition);                              \
@@ -139,6 +125,27 @@ extern __printf(1, 2) void __warn_printk(const char *fmt, ...);
 #endif
 #endif /* __WARN_FLAGS */
 
+#if defined(__WARN_FLAGS) && !defined(__WARN_printf)
+#define __WARN_printf(taint, arg...) do {                              \
+               instrumentation_begin();                                \
+               __warn_printk(arg);                                     \
+               __WARN_FLAGS("", BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\
+               instrumentation_end();                                  \
+       } while (0)
+#endif
+
+#ifndef __WARN_printf
+#define __WARN_printf(taint, arg...) do {                              \
+               instrumentation_begin();                                \
+               warn_slowpath_fmt(__FILE__, __LINE__, taint, arg);      \
+               instrumentation_end();                                  \
+       } while (0)
+#endif
+
+#ifndef __WARN
+#define __WARN()               __WARN_printf(TAINT_WARN, NULL)
+#endif
+
 /* used internally by panic.c */
 
 #ifndef WARN_ON