[PATCH 4/5] include: <asm-generic/bug.h>: make self-contained

Ahmad Fatoum a.fatoum at pengutronix.de
Sat Oct 30 07:17:38 PDT 2021


<asm-generic/bug.h> so far depended on a preceding <common.h> to get the
dump_stack() definition. Move dump_stack() to the new printk.h and drop
the remaining puts() use to make header self-contained.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 include/asm-generic/bug.h |  5 +++--
 include/common.h          |  9 ---------
 include/printk.h          | 10 ++++++++++
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 82b78261fc5d..6aa3eada0ec5 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -2,6 +2,8 @@
 #define _ASM_GENERIC_BUG_H
 
 #include <linux/compiler.h>
+#include <linux/kernel.h>
+#include <printk.h>
 
 #define BUG() do { \
 	printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
@@ -28,8 +30,7 @@
 	int __ret_warn_on = !!(condition);				\
 	if (unlikely(__ret_warn_on)) {					\
 		__WARN();						\
-		puts("WARNING: ");					\
-		printf(format);						\
+		printf("WARNING: " format);				\
 	}								\
 	unlikely(__ret_warn_on);					\
 })
diff --git a/include/common.h b/include/common.h
index 083b76cfedc9..e37630243e73 100644
--- a/include/common.h
+++ b/include/common.h
@@ -62,15 +62,6 @@ void ctrlc_handled(void);
 static inline void ctrlc_handled(void) { }
 #endif
 
-#ifdef CONFIG_ARCH_HAS_STACK_DUMP
-void dump_stack(void);
-#else
-static inline void dump_stack(void)
-{
-	printf("no stack data available\n");
-}
-#endif
-
 int parse_area_spec(const char *str, loff_t *start, loff_t *size);
 
 /* Just like simple_strtoul(), but this one honors a K/M/G suffix */
diff --git a/include/printk.h b/include/printk.h
index 0915efbadd51..baf2cca20213 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -47,4 +47,14 @@ extern void print_hex_dump(const char *level, const char *prefix_str,
 			   int prefix_type, int rowsize, int groupsize,
 			   const void *buf, size_t len, bool ascii);
 
+#ifdef CONFIG_ARCH_HAS_STACK_DUMP
+void dump_stack(void);
+#else
+static inline void dump_stack(void)
+{
+	printf("no stack data available\n");
+}
+#endif
+
+
 #endif
-- 
2.30.2




More information about the barebox mailing list