diff options
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/bug.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 8ceab7bcd8b4..a5250895155e 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -16,12 +16,15 @@ | |||
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | #ifndef HAVE_ARCH_WARN_ON | 18 | #ifndef HAVE_ARCH_WARN_ON |
19 | #define WARN_ON(condition) do { \ | 19 | #define WARN_ON(condition) ({ \ |
20 | if (unlikely((condition)!=0)) { \ | 20 | typeof(condition) __ret_warn_on = (condition); \ |
21 | printk("BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __FUNCTION__); \ | 21 | if (unlikely(__ret_warn_on)) { \ |
22 | dump_stack(); \ | 22 | printk("BUG: warning at %s:%d/%s()\n", __FILE__, \ |
23 | } \ | 23 | __LINE__, __FUNCTION__); \ |
24 | } while (0) | 24 | dump_stack(); \ |
25 | } \ | ||
26 | unlikely(__ret_warn_on); \ | ||
27 | }) | ||
25 | #endif | 28 | #endif |
26 | 29 | ||
27 | #else /* !CONFIG_BUG */ | 30 | #else /* !CONFIG_BUG */ |
@@ -34,21 +37,18 @@ | |||
34 | #endif | 37 | #endif |
35 | 38 | ||
36 | #ifndef HAVE_ARCH_WARN_ON | 39 | #ifndef HAVE_ARCH_WARN_ON |
37 | #define WARN_ON(condition) do { if (condition) ; } while(0) | 40 | #define WARN_ON(condition) unlikely((condition)) |
38 | #endif | 41 | #endif |
39 | #endif | 42 | #endif |
40 | 43 | ||
41 | #define WARN_ON_ONCE(condition) \ | 44 | #define WARN_ON_ONCE(condition) ({ \ |
42 | ({ \ | ||
43 | static int __warn_once = 1; \ | 45 | static int __warn_once = 1; \ |
44 | int __ret = 0; \ | 46 | typeof(condition) __ret_warn_once = (condition);\ |
45 | \ | 47 | \ |
46 | if (unlikely((condition) && __warn_once)) { \ | 48 | if (likely(__warn_once)) \ |
47 | __warn_once = 0; \ | 49 | if (WARN_ON(__ret_warn_once)) \ |
48 | WARN_ON(1); \ | 50 | __warn_once = 0; \ |
49 | __ret = 1; \ | 51 | unlikely(__ret_warn_once); \ |
50 | } \ | ||
51 | __ret; \ | ||
52 | }) | 52 | }) |
53 | 53 | ||
54 | #ifdef CONFIG_SMP | 54 | #ifdef CONFIG_SMP |