From 090252f695f30755ccab5717e3b366b13eb2eb8b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 6 Oct 2018 21:42:02 +0000 Subject: [PATCH] cst/include/backport.h: Add a printk_once() backport This patch is only relevant for regression testing SCST against kernel 2.6.29 or older. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7495 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/backport.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scst/include/backport.h b/scst/include/backport.h index 3455f3769..b3af751fb 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -569,6 +569,21 @@ static inline long get_user_pages_backport(unsigned long start, #endif #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) */ +/* See also commit f036be96dd9c ("printk: introduce printk_once()") */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +#define printk_once(fmt, ...) \ +({ \ + static bool __print_once __read_mostly; \ + bool __ret_print_once = !__print_once; \ + \ + if (!__print_once) { \ + __print_once = true; \ + printk(fmt, ##__VA_ARGS__); \ + } \ + unlikely(__ret_print_once); \ +}) +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) /* * See also patch "kernel.h: add pr_warn for symmetry to dev_warn,