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
This commit is contained in:
Bart Van Assche
2018-10-06 21:42:02 +00:00
parent c4d0b670e9
commit 090252f695
+15
View File
@@ -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,