diff --git a/scripts/generate-kernel-patch b/scripts/generate-kernel-patch index 9e671d092..ef83e25db 100755 --- a/scripts/generate-kernel-patch +++ b/scripts/generate-kernel-patch @@ -64,9 +64,10 @@ diff -uprN orig/linux-${kernel_version}/$2 linux-${kernel_version}/$2 @@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@ EOF if [ "${2%.[ch]}" != "$2" ]; then - sed -e 's/^ \([^ ]*:\)$/\1/' -e 's/^/+/' < "$1" + sed -e 's/sBUG(/BUG(/g' -e 's/sBUG_ON(/BUG_ON(/g' -e 's/^/+/' \ + -e 's/^ \([^ ]*:\)$/\1/' < "$1" else - sed -e 's/^/+/' < "$1" + sed -e 's/sBUG(/BUG(/g' -e 's/sBUG_ON(/BUG_ON(/g' -e 's/^/+/' < "$1" fi fi } diff --git a/scripts/specialize-patch b/scripts/specialize-patch index a93e6e48f..e3346e1a9 100755 --- a/scripts/specialize-patch +++ b/scripts/specialize-patch @@ -46,11 +46,13 @@ function evaluate(stmnt) { gsub("LINUX_VERSION_CODE", LINUX_VERSION_CODE, stmnt) + gsub("defined\\(INSIDE_KERNEL_TREE\\)", "1", stmnt) + do { last_stmnt = stmnt - pattern = "! ([0-9]+)" + pattern = "! *([0-9]+)" while (match(stmnt, pattern, op) != 0) { sub(pattern, op[1] == 0, stmnt) @@ -110,7 +112,7 @@ function handle_if() { # Only act on preprocessor conditional expressions with regard to the Linux # kernel version, and do not interpret other expressions. - if ($0 ~ "LINUX_VERSION_CODE") + if ($0 ~ "LINUX_VERSION_CODE" || $0 ~ "INSIDE_KERNEL_TREE") { $0 = evaluated } diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 4aeb39c30..14e3b4acf 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -39,6 +39,7 @@ #define DEBUG #endif +#if !defined(INSIDE_KERNEL_TREE) #ifdef DEBUG #ifndef EXTRACHECKS @@ -68,9 +69,10 @@ #define sBUG() BUG() #define sBUG_ON(p) BUG_ON(p) +#endif #endif -#ifndef WARN_ON_ONCE +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19) #define WARN_ON_ONCE(condition) ({ \ static int __warned; \ typeof(condition) __ret_warn_once = (condition); \