[PATCH 04/13] printk: Add printk_once

Alexander Stein alexander.stein at systec-electronic.com
Thu Mar 17 03:00:20 PDT 2016


This is needed by upcoming list_sort implementation.

Signed-off-by: Alexander Stein <alexander.stein at systec-electronic.com>
---
 include/printk.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/printk.h b/include/printk.h
index 822f64c..4b76ca1 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -92,6 +92,16 @@ static inline int pr_print(int level, const char *format, ...)
 #define debug(fmt, arg...)	__pr_printk(7, pr_fmt(fmt), ##arg)
 #define pr_vdebug(fmt, arg...)	__pr_printk(8, pr_fmt(fmt), ##arg)
 
+#define printk_once(fmt, ...)					\
+({								\
+	static bool __print_once	;			\
+								\
+	if (!__print_once) {					\
+		__print_once = true;				\
+		printk(fmt, ##__VA_ARGS__);			\
+	}							\
+})
+
 struct log_entry {
 	struct list_head list;
 	char *msg;
-- 
2.7.3




More information about the barebox mailing list