[PATCH V6 31/33] csky: fix compile error in linux/bug.h with SMP enabled
From: Guo Ren
Date: Thu Sep 27 2018 - 20:53:15 EST
In linux-4.19 we couldn't include linux/bug.h here when SMP enabled.
It'll cause compile error for bad include.
In file included from ./arch/csky/include/asm/bitops.h:70:0,
from ./include/linux/bitops.h:19,
from ./include/linux/kernel.h:11,
from ./include/asm-generic/bug.h:18,
from ./arch/csky/include/asm/bug.h:19,
from ./include/linux/bug.h:5,
from ./arch/csky/include/asm/cmpxchg.h:6,
from ./arch/csky/include/asm/atomic.h:8,
from ./include/linux/atomic.h:7,
from ./include/linux/rcupdate.h:38,
from ./include/linux/init_task.h:5,
from init/init_task.c:2:
The asm/bitops.h will lose asm/atomic.h for cycle include.
Signed-off-by: Guo Ren <ren_guo@xxxxxxxxx>
---
arch/csky/include/asm/cmpxchg.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/csky/include/asm/cmpxchg.h b/arch/csky/include/asm/cmpxchg.h
index 9b63dd7..ad53006 100644
--- a/arch/csky/include/asm/cmpxchg.h
+++ b/arch/csky/include/asm/cmpxchg.h
@@ -2,9 +2,10 @@
#define __ASM_CSKY_CMPXCHG_H
#ifdef CONFIG_CPU_HAS_LDSTEX
-#include <linux/bug.h>
#include <asm/barrier.h>
+extern void __bad_xchg(volatile void *ptr, int size);
+
#define __xchg(new, ptr, size) \
({ \
__typeof__(ptr) __ptr = (ptr); \
@@ -25,7 +26,7 @@
smp_mb(); \
break; \
default: \
- BUILD_BUG(); \
+ __bad_xchg(ptr, size), __ret = 0; \
} \
__ret; \
})
@@ -56,7 +57,7 @@
smp_mb(); \
break; \
default: \
- BUILD_BUG(); \
+ __bad_xchg(ptr, size), __ret = 0; \
} \
__ret; \
})
--
2.7.4